Android Date and Time Picker Dialog

Android Date and Time Picker Dialog

Date Picker Dialog and Time Picker Dialog in Android use to select a date and time, as it will be popup when you needed. While Time Picker and Date Picker widget occupy more space on screen. Dialogs are best way to solve this issue.

Example

In this tutorial, we are going to demonstrate the use of Date Picker through DatePickerDialog and TimePicker through TimePickerDialog.

VIDEO DEMO

1. Create a new project in Eclipse by navigating to File ⇒ New Android ⇒ Application Project and fill required details. (I kept my main activity name as MainActivity.java).

2. First create a simple layout as shown in video. The layout contains two buttons and two hidden textviews. The layout name is activity_main.xml.

3. Now add the following code to your MainActivtiy.java. In this code i showed how to display the time and date dialog box and get the selected date and time from dialog and show on textViews.

4. That’s all  –  run the app and you will get the output as shown in video.

Thanks. :)

Download Source Code – >

Leave a Comment

Comment (required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Name (required)
Email (required)