I am using MaterialCalendarView library, I want to select events dates problematically (no to be select by user in run time) which will be multiple, After reading the documentation i saw four cases.
I used SELECTION_MODE_NONE as i don't want user to select date. I tried this but it doesn't show me selected days which i passed.
private MaterialCalendarView materialCalendarView;
materialCalendarView = view.findViewById(R.id.newCal);
Calendar calendar = Calendar.getInstance();
calendar.set(2017, 12, 1);
calendar.set(2017, 12, 7);
calendar.set(2017, 12, 8);
calendar.set(2017, 12, 9);
calendar.set(2017, 12, 10);
materialCalendarView.addDecorator(new CurrentDayDecatator(getActivity()));
materialCalendarView.setDateSelected(calendar, true);
materialCalendarView.setSelectionMode(MaterialCalendarView.SELECTION_MODE_NONE);
How to implement that? where i am going wrong?
UPDATE: After taking the login of Umar and Manny i updated my code like this:
materialCalendarView.setSelectionMode(MaterialCalendarView.SELECTION_MODE_NONE);
Calendar calendar = Calendar.getInstance();
calendar.set(2017, 12, 14);
Calendar calendar2 = Calendar.getInstance();
calendar.set(2017, 12, 15);
Calendar calendar3 = Calendar.getInstance();
calendar.set(2017, 12, 16);
Calendar calendar4 = Calendar.getInstance();
calendar.set(2017, 12, 17);
materialCalendarView.addDecorator(new CurrentDayDecatator(getActivity()));
materialCalendarView.setDateSelected(calendar, true);
materialCalendarView.setDateSelected(calendar2, true);
materialCalendarView.setDateSelected(calendar3, true);
materialCalendarView.setDateSelected(calendar4, true);
So, now i get only the last date selected which is calendar4. But still i am unable to select multiple dates. and by default materialCalendarView selects today's date.
Okay, after doing lots of tweaks and with the suggestions of Manny and Umar i finally found the way how to set multiple days in materialCalendarView. So this is how it done.
I dont want user to select dates from calendar, so added this line in my code:
materialCalendarView.setSelectionMode (MaterialCalendarView.SELECTION_MODE_NONE);
Now i want to set multiple dates, for this i am creating multiple calendar objects and padding dates in it like this...
Calendar calendar = Calendar.getInstance();
calendar.set(2017, 11, 14);
Calendar calendar1 = Calendar.getInstance();
calendar1.set(2017, 11, 16);
And finally it was selecting multiple dates, but it is also selecting today's date which is not a problem. but now when i pass month as 12(december) it is showin me next month 12+1 which means january of next year. So for this i am passing a value less than what i want.
Final Code:
materialCalendarView.setSelectionMode (MaterialCalendarView.SELECTION_MODE_NONE);
Calendar calendar = Calendar.getInstance();
calendar.set(2017, 11, 14);
Calendar calendar1 = Calendar.getInstance();
calendar1.set(2017, 11, 16);
materialCalendarView.setDateSelected(calendar, true);
materialCalendarView.setDateSelected(calendar1, true);
Thanks Manny and Umar :)