Android 12 Developer Preview is here! Try it out, and give us your feedback!


open class TimePicker : Picker
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ android.widget.FrameLayout
   ↳ androidx.leanback.widget.picker.Picker
   ↳ androidx.leanback.widget.picker.TimePicker

TimePicker is a direct subclass of Picker.

This class is a widget for selecting time and displays it according to the formatting for the current system locale. 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). Otherwise, TimePicker retrieves the mode based on the current context. In 24-hour mode, TimePicker displays only the hour and minute columns.

This widget can show the current time as the initial value if useCurrentTime is set to true. Each individual time picker field can be set at any time by calling setHour(int), setMinute(int) using 24-hour time format. The time format can also be changed at any time by calling setIs24Hour(boolean), and the AM/PM picker column will be activated or deactivated accordingly. R.attr#is24HourFormat R.attr#useCurrentTime


Public constructors
<init>(context: Context!, attrs: AttributeSet!)

Constructor called when inflating a TimePicker widget.

<init>(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

Constructor called when inflating a TimePicker widget.

Public methods
open Int

Returns the currently selected hour using 24-hour time.

open Int

Returns the currently selected minute.

open Boolean

open Boolean

Only meaningful for a 12-hour time.

open Unit
onColumnValueChanged(columnIndex: Int, newValue: Int)

open Unit
setHour(@IntRange(0, 23) hour: Int)

Sets the currently selected hour using a 24-hour time.

open Unit
setIs24Hour(is24Hour: Boolean)

Sets whether this widget displays a 24-hour mode or a 12-hour mode with an AM/PM picker.

open Unit
setMinute(@IntRange(0, 59) minute: Int)

Sets the currently selected minute.

Inherited functions