设置android datepicker日期限制
问题描述:
我在android中使用datePicker来显示基于用户选择的日期的图像.我需要将上述日期限制为某些日期,例如2010年1月1日至2010年12月31日.我以为如此简单,但是我在哪里找不到关于如何限制这些日期的答案.
I am using datePicker in android to display images based on user selected dates. I need to limit said dates to certain days for instance Jan 1st 2010 to Dec 31st 2010. Simple as that i thought but no where can i find the answer on how to limit these dates.
有人知道如何限制Android DatePicker的日期
Does anyone know how to limit the dates for Android DatePicker
答
您可以设置:
dateDialog.getDatePicker().setMaxDate(new Date().getTime());
和
dateDialog.getDatePicker().setMinDate(new Date().getTime());
其中dateDialog是
where dateDialog is a
new DatePickerDialog()
,为MaxDate和MinDate设置的参数类型为 long
and the param type to set for MaxDate and MinDate is a long