CalendarListview
CalendarListview copied to clipboard
Need to show highlighted days only, not ranges
Hi, I am trying to change your code to achieve something that I want but unfortunately things are not going in the right direction. I have an ArrayList<CalendarDay> and all i want is to highlight the calendar list dates based on the data in the list i.e I don't want any ranges. Can you please help me out..?
+1
+1
+1
+1
+1
+1
+1
dayPickerView.setDateTime(new SimpleMonthAdapter.CalendarDay(startdate.getTime())); dayPickerView.setDateTime(new SimpleMonthAdapter.CalendarDay(enddate.getTime())); first is start date and second is end date. call in calendar activity.
@rugved-mahamune not recognized method .setDateTime.
public void setSelectedDateTime(CalendarDay calendarDay){
if (selectedDays.getFirst() != null && selectedDays.getLast() == null)
{
selectedDays.setFirst(null);
notifyDataSetChanged();
return;
}
selectedDays.setLast(calendarDay);
if(selectedDays.getLast().getDate().getTime() < selectedDays.getFirst().getDate().getTime()) {
CalendarDay tmp = selectedDays.getFirst();
selectedDays.setFirst(selectedDays.getLast());
selectedDays.setLast(tmp);
}
if (selectedDays.getFirst().month < calendarDay.month)
{
for (int i = 0; i < selectedDays.getFirst().month - calendarDay.month - 1; ++i)
mController.onDayOfMonthSelected(selectedDays.getFirst().year, selectedDays.getFirst().month + i, selectedDays.getFirst().day, selectedDays.getFirst().hourOfDay);
}
mController.onDaySelect(calendarDay, selectedDays, false);
mController.onDateRangeSelected(selectedDays);
}
else if (selectedDays.getLast() != null)
{
selectedDays.setFirst(calendarDay);
selectedDays.setLast(null);
mController.onDaySelect(calendarDay, selectedDays, false);
}
else {
selectedDays.setFirst(calendarDay);
mController.onDaySelect(calendarDay, selectedDays, false);
}
notifyDataSetChanged();
}
Add the above function to SimpleMonthAdpter and the below to DayPickerView public void setDateTime(SimpleMonthAdapter.CalendarDay dateTime){ mAdapter.setSelectedDateTime(dateTime); } sorry I forgot I added these methods.. feel free to ask if any more bugs :)
@rugved-mahamune Am Trying to do the same but there is extra bracket in your above method and no any method onDaySelect.