I created a CalendarView and I don't want to show previous months.
I tried this:
Calendar calendar = Calendar.getInstance();
int date = calendar.getActualMinimum(Calendar.DATE);
CalendarView calendar_view = (CalendarView) findViewById(R.id.calendar);
calendar_view.setMinDate(date);
Nothing seems to happen. The calendar works as normal.
Try calculating the date like this:
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DATE,Calendar.getInstance().getActualMinimum(Calendar.DATE));
long date = calendar.getTime().getTime();
and set this as minimum date:
calendar_view.setMinDate(date);
since calendar_view.setMinDate(date) needs long value that represents milliseconds.
calendar_view.setMinDate((new Date().getTime()));
works just fine
You can just set the min date as below.
Calendar c = Calendar.getInstance();
CalendarView cv = (CalendarView)findViewById(R.id.calendarView);
cv.setMinDate(c.getTimeInMillis());
来源:https://stackoverflow.com/questions/20681605/calendarview-minimum-date