Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have this type of time picker in Android?

I am developing an application in which i want to show time picker to set a time for reminder. Right now I am able to show a time-picker using preference screen like this

<org.example.android.TimePreference
 android:defaultValue="12:00"
 android:key="check_time"
 android:summary="Set your desired time for check"
 android:title="Check time" />

TimePreference.java file is inherited from this TimePicker in PreferenceScreen link. But I want to show this on button click in particular activity and set it values in EditText or in TextView. I don't want to use preferences.

So, I want to make the layout of this screen like below image.

enter image description here

like image 234
Juned Avatar asked Apr 02 '13 09:04

Juned


People also ask

Which method check current mode of time picker in Android?

is24HourView(): This method is used to check the current mode of the time picker. This method returns true if its 24 hour mode or false if AM/PM mode is set.

How do you use a time picker?

There are two primary methods for selecting time with the mobile time picker. Users can: Type in a specific value in the hour and minute fields. Select the hour or minute field from the text input and adjust the clock dial below to simultaneously change the corresponding time field above.

What is TimePicker dialog in Android?

android.app.TimePickerDialog. A dialog that prompts the user for the time of day using a TimePicker .

Which method is used to set the time picker in 12 hour format?

The time can be selected by hour, minute, and AM/PM picker columns. The AM/PM mode is determined by either explicitly setting the current mode through setIs24Hour(boolean) or the widget attribute is24HourFormat (true for 24-hour mode, false for 12-hour mode).


2 Answers

Please have a look at this tutorial . you will get the project over there . http://www.zainodis.com/2011/05/android-custom-timepicker.html

have a look at this example number picker.. like this you can change it into for time picker. Android Number Picker Dialog

like image 58
itsrajesh4uguys Avatar answered Oct 23 '22 11:10

itsrajesh4uguys


My answer is depending on the API level you are working with.

API level < 11: You'll have to backport the NumberPicker by copying it's source in your project and modifying it to your needs

API level >= 11: You can use the standard implementation of the NumberPicker and extend it to your needs.

like image 41
keyboardsurfer Avatar answered Oct 23 '22 09:10

keyboardsurfer