这是反向操作限制为选择过期日期。
我不知道这个方法的特殊方法。
但我这样解决了,这可能不是标准的,但对我有效public void onDateSet(DatePicker view, int selectedYear,
int selectedMonth, int selectedDay) {
final Calendar cf = Calendar.getInstance();
year = cf.get(Calendar.YEAR);
month = cf.get(Calendar.MONTH);
day = cf.get(Calendar.DAY_OF_MONTH);
//Log.e("year", selectedYear +"year" + year);
if (selectedYear
Toast.makeText(getApplicationContext(),
"Please choose future date", 1).show();
}
if (selectedMonth
if (selectedYear <= year) {
Toast.makeText(getApplicationContext(),
"Please choose future date", 1).show();
} else {
year = selectedYear;
month = selectedMonth;
day = selectedDay;
//set selected date into textview
shipdate.setText(new StringBuilder().append(month + 1)
. append("-").append(day).append("-").append(year)
. append(""));
}
}
if (selectedDay
if (selectedMonth <= month) {
if (selectedYear <= year) {
Toast.makeText(getApplicationContext(),
"Please choose future date", 1).show();
} else {
year = selectedYear;
month = selectedMonth;
day = selectedDay;
//set selected date into textview
shipdate.setText(new StringBuilder().append(month + 1)
. append("-").append(day).append("-")
. append(year).append(""));
}
} else {
year = selectedYear;
month = selectedMonth;
day = selectedDay;
//set selected date into textview
shipdate.setText(new StringBuilder().append(month + 1)
. append("-").append(day).append("-").append(year)
. append(""));
}
} else {
year = selectedYear;
month = selectedMonth;
day = selectedDay;
//set selected date into textview
shipdate.setText(new StringBuilder().append(month + 1)
. append("-").append(day).append("-").append(year)
. append(""));
}
}
};