Take the 2-minute tour ×

i've an app that has a DatePickerDialog. when i run the same code on different devices run different androids i get a different dialog. I understand the fact that in different versions of android the same widget can look athetically different but why should the wigets features differ from the same source code.

Below are the two widgets the first is android 2.3.3 and the second is in Android 4.0.4. I know they look different, but i want the date refected at the top of the widget as it is in the 2.3.3 version, but in the 4.0.4. Why is "Thursday, 08/Nov/2012" not displayed in 4.0.4?



share|improve this question
add comment

2 Answers

up vote 1 down vote accepted


Only the person who made that decision would be able to answer. If I had to take a stab at it I would guess they thought it was prettier somehow.

You are of course free to create your own date picker dialog that displays all of the information you want it to exactly how you want it to though. That is probably the best route to take if you are looking to get your application to be 100% consistent across all API versions.


Here is the source code for DatePickerDialog

It looks like you could override onDateChanged() of the DatePickerDialog to get the effect you want. am working on a sample chunk of code to post now.


Ok here is a snippet that is making it work correctly on a 4.0.3 device that I have access to.

   df = DateFormat.getDateInstance(DateFormat.FULL);
   mCal = Calendar.getInstance();
   // Create a date picker dialog
   DatePickerDialog datePickerDialog = new DatePickerDialog(this,datePickerDialogListener, year, month, day){
           mCal.set(Calendar.YEAR, year);
            mCal.set(Calendar.MONTH, month);
            mCal.set(Calendar.DAY_OF_MONTH, day);

You'll have to add in the code to set it the first time right before the dialog is shown.

share|improve this answer
ok thanks have you pointers on custom dialogs? –  turtleboy Nov 8 '12 at 15:05
DatePickerDialog has a setTitle() method that you can use to set a string up there. where you'll need to do that depends a bit on how it needs to behave. Does the date in the title need to change as the user changes the date with the buttons? –  FoamyGuy Nov 8 '12 at 15:12
yes it does need to change and also display the day of week. It's for carers that are looking up their rotas. It would be nice for them just to hit the +- buttons and not have to work out in their head what the date was last tuesday –  turtleboy Nov 8 '12 at 15:15
The DatePicker object has an onChanged() listener if you can get a reference to the DatePicker used by the dialog you should be able to call init() on it and pass it your own listener which can set the title of the dialog whenever the date is changed. See this question for info about DatePicker stackoverflow.com/questions/2051153/… –  FoamyGuy Nov 8 '12 at 15:25
hey thanks i'll have a look –  turtleboy Nov 8 '12 at 15:33
show 2 more comments

Originally (2.3 and earlier [honeycomb?]) the title was automatically updated to the current date. I think they realized that that might not always be desired (e.g. it's a pain to set a "plain text" title in 2.3, I know) so they changed it to be plain text. You can check both versions of the code: 2.3 and 4.0. I believe it's easier to make it look like 2.3 than 4.0, but you're going to have to customize it.

share|improve this answer
add comment

Your Answer


