android time picker example

Android Time Picker :

In android TimePicker view allows users to select a time of the day (Image is snap of Kitkat version Time Picker) , in either 24-hour mode or AM/PM mode. This example shows you how to use it.

Note : This example (Project) is developed in Eclipse Version Kepler, tested on Android 4.4.2 (KitKat Version) and SDK build-tools 22.6.3

Solution Stuff :

In this Android TimePicker example, you can use “android.widget.TimePicker” class to render a TimePicker.

You just need to drag and drop Time Picker widget in Android UI (according below figure) and write some code for Timepicker application in java class and xml file:

android timepicker

Complete Source code :

1. Put this code in main_activity.xml

The TimePicker displays a standard UI to enable users to set a time. By default, it displays the time in the AM/PM format.

2. Put this java code in MainActivity.class

If you want to display the time in the 24-hour format, you use the setIs24HourView() method. To programmatically get the time set by the user, use the getCurrentHour() and getCurrentMinute() methods. Figure shows the TimePicker in action.

android time picker

Android TimePicker Example Source code Download :

  1. Android Developer

    hi, i need your help on this. Want to create a custom time picker which you showed at the top right of this page. Can you give a hint on how i can develop that

Leave a Reply