dee*_*eep 9 android date datepicker android-datepicker
我想在android中禁用日期选择器的过去日期.我可以通过使用来做到这一点
dialog.getDatePicker().setMinDate(System.currentTimeMillis() - 1000);
Run Code Online (Sandbox Code Playgroud)
这工作正常,日期选择器中的过去日期看起来已禁用.但我仍然可以点击之前的日期并选择它.怎么不让这种情况发生?下面是我的约会选择器的截图: -
这是我的代码,我禁用过去的日期: -
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
mActivity = new WeakReference<CreateEvent>(
(CreateEvent) getActivity());
DatePickerDialog dialog = new DatePickerDialog(getActivity(), this, year, month, day);
if(callingView==fromDate){
dialog.getDatePicker().setMinDate(System.currentTimeMillis() - 1000);
}else if (callingView==toDate){
dialog.getDatePicker().setMinDate(fromD);
}
// Create a new instance of DatePickerDialog and return it
return dialog;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4701 次 |
| 最近记录: |