Android time picker dialog


Download android time picker sample

Sometimes, we need to capture time from user. If we forced them to type required time then there is chance for mis-typing and also selecting a time is quite easy compare to type.

In android, we can use in built timePicker dialog to capture time from user.

Android time picker dialog Android time picker dialog


Example


Step 1: Create a new project in Android Studio and name it Android time picker.

Step 2: Open res -> drawable and add a xml resource file with a name date_selector.xml. Now, replace the code of date_selector.xml with the below given code.

date_selector.xml

Step 3: Open MainActivity.java and replace its code with below given code.

MainActivity.java

Step 4:Open res -> drawable -> activity_main.xml and replace the code with code of activity_main.xml with the below given code.

activity_main.xml

Step 5:Clean and run your project to see the result.

Share & Like

Tutorial topics

About ApnaTutorials.com

ApnaTutorials.com is for Java, J2ee, Html5 and android developers. All tutorials are well explained and are easy to understand. We have tested every tutorials on our developement environment before posting it in public domain.