Android DatePicker/Dialog 使用最小/最大日期显示不正确的月/秒 [英] Android DatePicker/Dialog displaying incorrect month/s using min/max date
问题描述
我正在使用 DatePickerDialog 和 DatePicker 来设置特定范围.
I'm using the DatePickerDialog and the DatePicker to set a specific range.
datePicker.setMinDate(minDate);
datePicker.setMaxDate(maxDate);
如果我的最小/最大 - 日期在一个月的范围内(例如:7.2.2014 - 27.2.2014),我仍然会在对话框中显示相邻的月份(一月、三月).如果我选择上个月(一月),对话框会自动切换到 minDate,月份切换回二月.未来一个月也是如此.
If my min/max - dates are in the range of one month (eg.: 7.2.2014 - 27.2.2014), i still get the neighbour months displayed in the dialog (Jan, Mar). If i choose the last month (Jan), the dialog automatically swaps to the minDate and the month switches back to Feb. Same thing for the future month.
有没有办法解决这个问题,以便我只显示在我范围内的月份?
Is there a way to fix this, so that i only get the months displayed, which are in my range?
推荐答案
在 Android Month 从零开始......
In Android Month start from zero.....
所以你必须在 1 月使用 0,在 12 月使用 11
So u have to use zero for january and 11 for December
这篇关于Android DatePicker/Dialog 使用最小/最大日期显示不正确的月/秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!