Android DatePicker shows unavailable months when using min/max limits

笑着哭i 提交于 2019-12-04 23:30:45

OPTION 1. You could use android-times-square

and give in a custom date range so that it fades out the unavailable dates, gives more visual representation too

Calendar nextYear = Calendar.getInstance();
nextYear.add(Calendar.YEAR, 1);

CalendarPickerView calendar = (CalendarPickerView) findViewById(R.id.calendar_view);
Date today = new Date();
calendar.init(today, nextYear.getTime())
    .inMode(RANGE);

I fixed that issue by resetting the current time to midnight:

Calendar date = Calendar.getInstance();
// reset hour, minutes, seconds and millis
date.set(Calendar.HOUR_OF_DAY, 0);
date.set(Calendar.MINUTE, 0);
date.set(Calendar.SECOND, 0);
date.set(Calendar.MILLISECOND, 0);
datePicker.setMaxDate(date.getTimeInMillis());
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!