setMinDate()进行的DatePicker [英] setMinDate() for DatePicker
问题描述
我看到在好几个地方堆栈溢出这个问题,但所提供的答案不为我工作,所以我在这里。)
我需要动态设置日期选择器的最小日期为当前日期。我最小的API为12。
我试过这样:
日历minCalendar = Calendar.getInstance();
minCalendar.set(Calendar.MILLISECOND,minCalendar.MILLISECOND - 1000);DatePicker的endDatePicker =(的DatePicker)findViewById(R.id.datePicker2);
endDatePicker.setMinDate(minCalendar.getTimeInMillis());
我没有得到任何错误,只是日期选择器没有设置为今天。它被设置为1964年10月......
请帮我...
EDITED
我也试过这一点,但同样的效果:
endDatePicker.setMinDate(System.currentTimeMillis的() - 1000);
从<一个href=\"http://stackoverflow.com/questions/16664562/setting-mindate-on-datepicker-moves-calendarview-to-1964/16671925#16671925\">my类似的问题和答案:
//日历的观点是错误的级联。
//周围的工作通过明确禁用它。
datePicker.setCalendarViewShown(假);
如果用日期选取器工作日历视图是对你的一个优先事项,我会考虑分叉平台code和修复的错误在那里。
I saw this question on stack overflow in several places, but the given answers does not work for me, so here I am :).
I need to set a date picker's minimum date dynamically to the current date. My minimum API is 12.
I tried this:
Calendar minCalendar = Calendar.getInstance();
minCalendar.set(Calendar.MILLISECOND, minCalendar.MILLISECOND - 1000);
DatePicker endDatePicker = (DatePicker) findViewById(R.id.datePicker2);
endDatePicker.setMinDate(minCalendar.getTimeInMillis());
I don't get any errors, only the date picker is not set to today. It is set to 'October 1964'....
Please help me...
EDITED
I also tried this, but the same effect:
endDatePicker.setMinDate(System.currentTimeMillis() - 1000);
From my similar question and answer:
// Calendar view is a cascade of bugs.
// Work around that by explicitly disabling it.
datePicker.setCalendarViewShown(false);
If a working calendar view with the date picker is a priority for you, I'd consider forking the platform code and fixing the bugs there.
这篇关于setMinDate()进行的DatePicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!