DatePickerDialog dpd= new DatePickerDialog(this, pDateSetListener, pYear, pMonth, pDay);
DatePickerDialog da = new DatePickerDialog(this, pDateSetListener, pYear, pMonth, pDay);
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, 1);
Date newDate = c.getTime();
dpd.getDatePicker().setMinDate(newDate.getTime());
dpd.getDatePicker().setMaxDate(date+(1000*60*60*24*60));
return dpd;
我错在哪里,因为这不起作用,请帮忙。
答案 0 :(得分:0)
这对我有用了尝试
private void handelDate(){
if(minDate!=null){
Calendar min= Calendar.getInstance();
min.setTime(minDate);
min.set(Calendar.HOUR_OF_DAY, min.getMinimum(Calendar.HOUR_OF_DAY));
min.set(Calendar.MINUTE, min.getMinimum(Calendar.MINUTE));
min.set(Calendar.SECOND, min.getMinimum(Calendar.SECOND));
min.set(Calendar.MILLISECOND, min.getMinimum(Calendar.MILLISECOND));
CalendarView cv = datePicker.getCalendarView(); // should check for null
long cur = cv.getDate();
int d = cv.getFirstDayOfWeek();
try {
datePicker.setMinDate(min.getTimeInMillis());
} catch (Exception e) {
e.printStackTrace();
}
cv.setDate(cur + 1000L*60*60*24*40);
cv.setFirstDayOfWeek((d + 1) % 7);
cv.setDate(cur);
cv.setFirstDayOfWeek(d);
}
if(maxDate!=null){
datePicker.setMaxDate(maxDate.getTime());
}
}