CosmoCalendar icon indicating copy to clipboard operation
CosmoCalendar copied to clipboard

Select date programmatically

Open EmmanuelVmb opened this issue 6 years ago • 3 comments

Hi,

Is it possible to select a day in the calendar programmatically? So I want to do something like calendar.SelectDate(date); and that it then selects the date in the calendar visually.

Thanks!

EmmanuelVmb avatar Aug 13 '18 07:08 EmmanuelVmb

Hi,

after setting your selection manage, for example:

calendarView.setSelectionManager(new RangeSelectionManager(new OnDaySelectedListener() { @Override public void onDaySelected() { } }));

then you can set a first and a second day, to specify your range:

` Day firstDay = new Day(dateStart); Day secondDay = new Day(dateEnd);

        calendarView.clearSelections();
        calendarView.getSelectionManager().toggleDay(firstDay);
        calendarView.getSelectionManager().toggleDay(secondDay);

` hope this helps

maccas-devs avatar Oct 17 '18 09:10 maccas-devs

Hi,

after setting your selection manage, for example:

calendarView.setSelectionManager(new RangeSelectionManager(new OnDaySelectedListener() { @Override public void onDaySelected() { } }));

then you can set a first and a second day, to specify your range:

` Day firstDay = new Day(dateStart); Day secondDay = new Day(dateEnd);

        calendarView.clearSelections();
        calendarView.getSelectionManager().toggleDay(firstDay);
        calendarView.getSelectionManager().toggleDay(secondDay);

` hope this helps

After trying out your solution using (.setSelectionManager), I'm only getting a StackOverflow error, I could not see the selected dates visually, what could be the issue?

bryan-ibrahim avatar Jun 11 '19 03:06 bryan-ibrahim

How do i set the current month the calendar should should show pro grammatically since i tried settingManager and selection manager but it does not help set current month;

david-macharia avatar Dec 18 '19 14:12 david-macharia