如何在 Android TimePickerDialog 中隐藏或禁用分钟小部件?
我正在开发一个应用程序,我想让用户能够仅选择“小时”和“上午/下午”,但“分钟”小部件应该按照我提到的那样进行修复。我正在使用 TimePickerDialog。 有可能这样做吗?
I'm working on an application where i want to give user the ability of just to select Hours and AM/PM but Minutes widget should be fixed as i mentioned. I am using TimePickerDialog.
Is there any possibility of doing that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定,但您可以将 Android 轮与 Timepicker 一起使用。
http://code.google.com/p/android-wheel/source/browse/trunk/wheel/src/kankan/wheel/demo/TimeActivity.java?r=16
并查看此链接:
<一href="http://code.google.com/p/android-wheel/" rel="nofollow">http://code.google.com/p/android-wheel/
I am not sure but you can use Android wheel with Timepicker.
http://code.google.com/p/android-wheel/source/browse/trunk/wheel/src/kankan/wheel/demo/TimeActivity.java?r=16
and also check out this link:
http://code.google.com/p/android-wheel/
没有直接的办法。 TimePickerDialog 甚至不给你它正在使用的 TimePicker。因此,您必须从 TimePickerDialog.java 复制代码以满足您自己的需要。
另一部分是 TimePicker 不允许您访问其子视图(id 不公开),因此您还需要从 Android 源复制 time_picker.xml,并创建您自己的 TimePicker 视图。
好消息是,您可以从 Android 源代码复制,并且提到的两个源代码都相当短,因此完成这项工作相对容易。
There's no direct way. TimePickerDialog doesn't even give you TimePicker that it's using. So you'd have to copy code from TimePickerDialog.java to suit your own needs.
Another part is that TimePicker doesn't give you access to its sub-views (id's are not public), so you'd also need to copy time_picker.xml from Android sources, and create your own TimePicker view.
Good news is that you can copy from Android source code, and both mentioned sources are rather short, so it's relatively easy task to make this work.