带有日期选择器的 Android 微调器,例如 Google 日历应用 [英] Android spinner with date picker, like Google Calendar app

查看:34
本文介绍了带有日期选择器的 Android 微调器,例如 Google 日历应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用一个看起来像微调器的文本框来激活日期选择器对话框.这是在 ICS 上的 Google 日历应用和通讯录应用(用于生日)中完成的.我是否需要使用微调器,如果需要,如何将其输入视图更改为日期选择器?或者,如果没有,我如何让文本视图具有通常表示微调器的小三角形?

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.这可以按此处所示完成:https://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: https://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 微调器,例如 Google 日历应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆