设置android datepicker日期限制 [英] Set android datepicker date limits
本文介绍了设置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
这篇关于设置android datepicker日期限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文