ElTourero
ElTourero

Reputation: 51

Android: timepicker and datepicker in the same dialog box

I am developing an app for android. I have created a timepickerdialog and a datepickerdialog, but the problem is, both of them run in different dialog boxes, which is not what the way I want my app to work :-S Is there any way to create a single dialogbox with both time and date picker dialog boxes in it together?

Thx

Upvotes: 5

Views: 23736

Answers (3)

Ovid
Ovid

Reputation: 123

I have created a custom Alert Dialog as in the Google tutorial. I replaced the ImageView and the TextView with a DatePicker and a TimePicker. I changed the following line:

View layout = inflater.inflate(R.layout.custom_dialog,
                           (ViewGroup) findViewById(R.id.layout_root));

with this:

View layout = inflater.inflate(R.layout.dialog_date_time, 
                           (ViewGroup) findViewById(R.id.datePicker));

For whatever reason the first gave an error, but the second worked. Anyway, I can use the two views in the same dialog window now.

Upvotes: 2

Jaydeep Khamar
Jaydeep Khamar

Reputation: 5985

call time picker dialog in datepicker's update time method,It'll not be called at the same time but when you press datepicker's set button,Time picker dialog will open . The method is given in the answer of this link: DateTime picker in android application

Upvotes: 0

BFil
BFil

Reputation: 13096

You can find a DateTimePicker implementation here:

http://code.google.com/p/datetimepicker/

Upvotes: 17

Related Questions