微调模式下的Android DatePicker不显示日期 [英] Android DatePicker in spinner mode not showing date
问题描述
我在微调器模式下使用 DatePicker
,并设置了最小和最大限制。然后将日期更新为最大值。显示 DatePickerDialog
时,日期列没有值。当我点击/向上滚动或向下滚动时,将显示这些值。
I'm using DatePicker
in spinner mode, and sets min and max limit. Then updates the date as max value. Date column does not have a value when the DatePickerDialog
shown. When I tap/scroll up or down the values are shown.
MyLayout:
<DatePicker
android:id="@+id/date_picker"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/spacing_default"
android:layout_marginRight="@dimen/spacing_default"
android:datePickerMode="spinner"
android:calendarViewShown="false" />
Java部分:(在 onViewCreated
)
private static final int DATE_PICKER_MONTH_OFFSET = 1;
private static final int DATE_PICKER_MIN_DATE_OFFSET_IN_MIN = 1;
datePicker.setMinDate( now().minusMinutes(
DATE_PICKER_MIN_DATE_OFFSET_IN_MIN).getMillis() );
datePicker.setMaxDate( activationDateTime.getMillis() );
datePicker.updateDate( activationDateTime.getYear(),
activationDateTime.getMonthOfYear() - DATE_PICKER_MONTH_OFFSET,
activationDateTime.getDayOfMonth() );
问题屏幕截图:
要使日期部分显示在 DatePickerDialog
?
更新/编辑:
当设置的值与最大限制相同时,选择器似乎显示一个空视图。我可以通过先放置 datePicker.updateDate
然后调用<$ c $来解决问题(在启动 DatePicker
时) c> datePicker.setMaxDate 。 setMaxDate
将验证先前的值并正确设置。
但是现在当我将月份从7月滚动到8月时,我也会遇到相同的问题,而日视图将变为空!
The seems that picker show an empty view when the value set is same as the max limit. I could resolve the issue (while launching the DatePicker
) by placing datePicker.updateDate
first and then call datePicker.setMaxDate
. The setMaxDate
will validate the previously value and sets correctly.
But now I face the same problem when I scroll the month from Jul to Aug, the day view becomes empty!
任何解决方案/建议都值得赞赏。
Any solution/suggestion appreciated.
推荐答案
android小部件 DatePicker
中似乎有错误c $ c> spinner 模式。 Google问题跟踪器中已经存在这样的票证: https://issuetracker.google.com/issues/ 64508670
There seems to have bug in the android widget DatePicker
in the spinner
mode. Already such a ticket present in the Google issue tracker also : https://issuetracker.google.com/issues/64508670
不幸的是,问题跟踪器中没有解决方法或建议。
Unfortunately no work around or suggestions available in the issue tracker.
这篇关于微调模式下的Android DatePicker不显示日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!