Android的微调与日期选取器,如谷歌日历应用程序 [英] Android spinner with date picker, like Google Calendar app
问题描述
我试图让这看起来像一个微调激活日期选择器对话框一个文本框。这是两个在ICS的谷歌日历应用程序和联系人应用程序(用于生日)完成。我需要用一个微调,如果是的话我怎么改变它的输入视图是一个日期选择器?或者,如果没有,我怎么得到一个文本视图有小三角形通常表示一个微调?
I'm trying to get a text box that looks like a spinner to activate a date picker dialog. This is done in both the Google Calendar app and the Contacts app (for birthdate) on ICS. Do I need to use a spinner, and if so how do I change it's input view to be a date picker? Or if not, how do I get a text view to have the little triangle that usually indicates a spinner?
推荐答案
在他的回答Twaddington的评论实际上是正确的做法。 你需要的是创建一个文本视图,并应用该样式
Twaddington's comment on his answer is actually the right approach. What you need is to create a text view and apply the style
style="@android:style/Widget.DeviceDefault.Light.Spinner"
然后,您可以创建的文本视图点击监听器,并用它来打开一个DatePickerDialog。这可以完成,如下所示: http://stackoverflow.com/a/8127571/332738
(如果你按照这个例子,记得一个默认的构造函数添加到 DatePickerDialogFragment
让您的应用程序无法在旋转崩溃)
Then you can create a click listener on the text view and use it to open a DatePickerDialog. That can be accomplished as shown here: http://stackoverflow.com/a/8127571/332738
(If you follow the example, remember to add a default constructor to DatePickerDialogFragment
so that your app does not crash on rotate)
这篇关于Android的微调与日期选取器,如谷歌日历应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!