DatePicker setMinDate和setMaxDate

时间:2015-11-15 07:12:39

标签: java android datepicker calendar

为什么在我的手机(Android 5.0.1)中,结果是这样的?标记选择日期的蓝色边框始终比所选日期早1周?但是在我的模拟器4.4.2中没有这样的问题。

这就是我设置最小和最大日期所做的:

Calendar minCal = Calendar.getInstance();
int currentYear = mDatePicker.getYear();
int currentMonth = mDatePicker.getMonth();
int currentDayOfMonth =  mDatePicker.getDayOfMonth();
minCal.set(currentYear, currentMonth, currentDayOfMonth, 0, 0, 0);
Calendar maxCal = (Calendar) minCal.clone();
maxCal.set(currentYear, currentMonth+2, currentDayOfMonth, 0, 0, 0);
mDatePicker.setMinDate(minCal.getTimeInMillis());
mDatePicker.setMaxDate(maxCal.getTimeInMillis());
mDatePicker.updateDate(currentYear, currentMonth, currentDayOfMonth);

enter image description here

0 个答案:

没有答案