在所有android手机中运行的日期选择器对话框在我按应用程序崩溃时预期为4.4.2
这将在onclick方法中
DatePickerDialog datePickerDialog=
new DatePickerDialog(this, date, myCalendar
.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
myCalendar.get(Calendar.DAY_OF_MONTH));
datePickerDialog.getDatePicker().setMinDate(Calendar.getInstance().getTimeInMillis());
datePickerDialog.getDatePicker().setCalendarViewShown(false);
datePickerDialog.show();
这将处于活动状态
DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub
myCalendar.set(Calendar.YEAR, year);
myCalendar.set(Calendar.MONTH, monthOfYear);
myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
updateLabel();
}
};
当用户按下日期时,这会将文本设置为文本视图
private void updateLabel() {
String myFormat = "dd/MM/yy"; //In which you need put here
SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
Duedate.setText(sdf.format(myCalendar.getTime()));
}
我的应用程序崩溃时我看到了此日志
Fatal Exception: java.lang.IllegalArgumentException
fromDate: Sat Jun 01 15:35:26 IST 2019 does not precede toDate: Sat Jun 01 15:35:26 IST 2019