這個代碼日期選擇器不工作的API 26
Calendar calendarStart = Calendar.getInstance();
startYear = calendarStart.get(Calendar.YEAR) + 543;
startMonth = calendarStart.get(Calendar.MONTH);
startDay = calendarStart.get(Calendar.DAY_OF_MONTH) - 7;
dateStartPickerDialog = new DatePickerDialog(
AccountReportActivity.this, R.style.DatePicker,
AccountReportActivity.this, startYear, startMonth, startDay);
dateStartPickerDialog.getDatePicker().setMinDate(calendarStart.getTimeInMillis());
calendarStart.add(Calendar.YEAR, 543);
dateStartPickerDialog.getDatePicker().setMaxDate(calendarStart.getTimeInMillis());
此錯誤代碼
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.IllegalArgumentException: timeInMillis must be between the values of getMinDate() and getMaxDate()
at android.widget.DayPickerView.setDate(DayPickerView.java:307)
at android.widget.DayPickerView.setDate(DayPickerView.java:286)
at android.widget.DayPickerView.setDate(DayPickerView.java:275)
at android.widget.DatePickerCalendarDelegate.onDateChanged(DatePickerCalendarDelegate.java:405)
at android.widget.DatePickerCalendarDelegate.init(DatePickerCalendarDelegate.java:376)
at android.widget.DatePicker.init(DatePicker.java:228)
at android.app.DatePickerDialog.<init>(DatePickerDialog.java:133)
at android.app.DatePickerDialog.<init>(DatePickerDialog.java:109)
at com.splanet.aplaysellers.activity.report.AccountReportActivity.setUpCurrentStartDate(AccountReportActivity.java:103)
at com.splanet.aplaysellers.activity.report.AccountReportActivity.initWidget(AccountReportActivity.java:75)
at com.splanet.aplaysellers.activity.report.AccountReportActivity.onCreate(AccountReportActivity.java:51)
at android.app.Activity.performCreate(Activity.java:6980)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
請幫助我,我試圖通過各種渠道來解決問題。它不能解決這個問題。
它不工作只API 26 –
沒有getMinDate()和getMaxDate()在我的代碼 –
dateStartPickerDialog.getDatePicker()setMinDate(calendarStart.getTimeInMillis())。 calendar日曆.add(Calendar.YEAR,543); calendarStart.add(Calendar.YEAR,543);dateStartPickerDialog.getDatePicker()。setMaxDate(calendarStart.getTimeInMillis()); 刪除這些行。 –