开发者

Changing the title on a TimePicker?

I'm trying to look for a solution to change the title on a TimePicker dialog. Right now it say开发者_运维问答s 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?


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)


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.


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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜