Changing the title on a TimePicker?

蹲街弑〆低调 提交于 2019-12-22 04:33:08

问题


I'm trying to look for a solution to change the title on a TimePicker dialog. Right now it says whatever the system time is (ex. "12:23 AM") but I want to change this to something a little more descriptive. Does anyone have any suggestions?


回答1:


By request. :)

By TimePicker dialog do you mean the actual TimePickerDialog? Because that has a setTitle(CharSequence text) method. The TimePickerDialog is what is used in the official tutorial. http://developer.android.com/reference/android/app/AlertDialog.html#setTitle(java.lang.CharSequence)




回答2:


This question is rather old, but it shows up on Google results if you search this question. So, I thought I'll post my solution.

DatePicker has setCustomTitle(View view), where you can define your own view (e.g. TextView with your custom text) to be used as a title. This one does not update when changing values.




回答3:


I dont know how to reply to the comments below question, so I use "Answer". By looking into source code: SourceCode

You may realize that OnTimeChangedListener is implemented by TimePickerDialog. To avoid title changed while adjusting time, you may derived from TimePickerDialog and override public void onTimeChanged(TimePicker view, int hourOfDay, int minute);

Notice, dont call super version, or it will setTitle again...



来源:https://stackoverflow.com/questions/5375306/changing-the-title-on-a-timepicker

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