Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 901
Sunandmoon Avatar asked Mar 21 '11 08:03

Sunandmoon


3 Answers

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)

like image 82
Codemonkey Avatar answered Nov 15 '22 09:11

Codemonkey


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.

like image 29
p9teufel Avatar answered Nov 15 '22 10:11

p9teufel


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

like image 43
ap41047 Avatar answered Nov 15 '22 08:11

ap41047