I\'m debugging an issue where the CalendarView
in a DatePicker
moves to October 1964 if there is a non-default minimum date set. This reproduces at
The above answers are right on about the sources of this bug. For my application, I'm using this workaround:
Every time the DatePicker's date or minDate is changed, call the following routine with the date that should be selected in the picker/calendar:
private void fixUpDatePickerCalendarView(Calendar date) {
// Workaround for CalendarView bug relating to setMinDate():
// https://code.google.com/p/android/issues/detail?id=42750
// Set then reset the date on the calendar so that it properly
// shows today's date. The choice of 24 months is arbitrary.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
final CalendarView cal = datePicker.getDatePicker().getCalendarView();
if (cal != null) {
date.add(Calendar.MONTH, 24);
cal.setDate(date.getTimeInMillis(), false, true);
date.add(Calendar.MONTH, -24);
cal.setDate(date.getTimeInMillis(), false, true);
}
}
}