First make a choice of time and date in the same dialog box
Here I can help you with something: you can create a layout consisting of DatePicker and TimePicker in LinearLayout with the orientation set to vertical.
custom_dialog.xml:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <DatePicker android:id="@+id/datePicker1" android:layout_width="wrap_content" android:layout_height="wrap_content" > </DatePicker> <TimePicker android:id="@+id/timePicker1" android:layout_width="wrap_content" android:layout_height="wrap_content" > </TimePicker> </LinearLayout>
Then use this layout to create a dialog.
Dialog dialog = new Dialog(mContext); dialog.setContentView(R.layout.custom_dialog); dialog.setTitle("Custom Dialog");
To respond to the user interacting with your TimePicker , follow these steps:
TimePicker tp = (TimePicker)dialog.findViewById(R.id.timepicker1); tp.setOnTimeChangedListener(myOnTimechangedListener);
To get the values ββfrom the Date- and TimePicker when the user has finished configuring them, add the OK button to your dialog, and then read the date and time values ββfrom the Date- and TimePicker when the user clicks OK.
To do something that looks exactly the same as in your screenshots, I recommend that you do whatever you want with your own logic.
Bhavesh Patadiya Jan 10 '13 at 9:17 2013-01-10 09:17
source share