Android 倒计时器的小时/分钟选择器
我正在尝试实现类似倒计时器的东西,在 0 时播放警报。我希望能够设置计时器响起之前等待的时间,我想知道是否有一个 UI 小部件或元素可以提供这种选择功能。
基本上,android有类似iPhone选择旋转轮的东西吗?或者是否有某种类型的时间选择器允许选择任意数量的小时和分钟? Android 中的时间选择器小部件有一个不必要的 AM/PM 标签。
我是否需要实现自己的自定义 UI 才能实现此目的?
I'm trying to implement something like a countdown timer that plays an alarm at 0. I want to be able to set the amount of time to wait before the timer goes off and I'm wondering if there's a UI widget or element that provides this kind of selection functionality.
Basically, does android have something like the iPhone's selection spinwheel? Or is there some type of timepicker that allows selection of an arbitrary number of hours and minutes? The timepicker widget in android has an unnecessary AM/PM label.
Do I need to implement my own custom UI to achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用默认的 TimePickerDialog 并重写 onTimeChanged 方法来自行更新标题:
You can use the default TimePickerDialog and override the onTimeChanged method to update the title yourself:
是的,你可以一起破解一个。尽管由于 API 的变化,这段代码的生命周期很可能会很短。
然后在布局中放置其中几个:
setCurrent 设置选择器的索引,在 foo 的情况下意味着值“$07”。 setRange 设置要在选择器中显示的值。
祝你好运。
Yes, you can hack one together. It's a distinct possibility that this code will have a short lifespan though due to changes in the API.
And then drop a couple of these in your layout:
setCurrent set's the index of the picker which in the case of foo means a value of "$07". setRange sets the values to display in the picker.
Good luck.