How to Hide or Disable Minutes widget in Android TimePickerDialog?

二次信任 提交于 2019-12-11 08:48:03

问题


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?


回答1:


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/




回答2:


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.



来源:https://stackoverflow.com/questions/7643532/how-to-hide-or-disable-minutes-widget-in-android-timepickerdialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!