Android Date and Time Picker Dialog - Androhub

Time and Date 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. :)

 

2 Comments

JAWAHER RAVICHANDRAN
Monday, November 12th, 2018

its not workinggg

Dr. Droid
Monday, November 12th, 2018

Hi Jawaher,

Can you tell me what issue you are facing?

Thanks

Post comment

Your email address will not be published. Required fields are marked *