如何在 TimePickerDialog 中禁用分钟更改 [英] How to disable minutes change in TimePickerDialog
问题描述
是否只需要允许更改时间,怎么办?
Is need to allow only to change hours, how can it be done?
在简单的 TimePicker 中,我可以设置 TimePicker.OnTimeChangedListener 接口,但是 TimePickerDialog 中没有该接口.
In simple TimePicker, i can set the TimePicker.OnTimeChangedListener interface, but this interface is not available in TimePickerDialog.
推荐答案
您可以复制原始 Widget 的源代码及其布局,并将其作为库"类包含在您自己的项目中.您还需要更新源对 R 的引用.通过布局,您可以显示任何您想要的关于没有可编辑分钟的内容.由于这是作业,请务必正确注意您正在从 Android 源库自定义小部件.
You can copy the source of the original Widget and its layout and include it in your own project as a "library" class. You will also need to update the source's references to R. With the layout you can show anything you'd like in regards to not having minutes being editable. Since this is homework be sure to correctly note that you're customizing widget from Android source library.
这篇关于如何在 TimePickerDialog 中禁用分钟更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!