TimePicker


public class TimePicker extends Picker


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 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, setMinute using 24-hour time format. The time format can also be changed at any time by calling setIs24Hour, and the AM/PM picker column will be activated or deactivated accordingly. is24HourFormatuseCurrentTime

Summary

Public constructors

TimePicker(Context context, AttributeSet attrs)

Constructor called when inflating a TimePicker widget.

TimePicker(Context context, AttributeSet attrs, int defStyleAttr)

Constructor called when inflating a TimePicker widget.

Public methods

int

Returns the currently selected hour using 24-hour time.

int

Returns the currently selected minute.

boolean
boolean

Only meaningful for a 12-hour time.

void
onColumnValueChanged(int columnIndex, int newValue)

Classes extending Picker can override this function to supply the behavior when a list has been scrolled.

void
setHour(@IntRange(from = 0, to = 23) int hour)

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

void
setIs24Hour(boolean is24Hour)

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

void
setMinute(@IntRange(from = 0, to = 59) int minute)

Sets the currently selected minute.

Inherited Constants

From android.view.View
static final int
static final int
static final int
static final int
static final int
static final int
static final Property<ViewFloat>
static final int
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE = "creditCardExpirationDate"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = "creditCardExpirationDay"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = "creditCardExpirationMonth"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR = "creditCardExpirationYear"
static final String
static final String
AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE = "creditCardSecurityCode"
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int
static final int
static final int
static final int
static final int
static final int
static final int[]
static final int[]
static final int[]
static final int[]
static final int
static final int
static final int
static final int
static final int
static final int
static final int
GONE = 8
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
KEEP_SCREEN_ON = 67108864
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
NO_ID = -1
static final int
static final int
static final int
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final float
static final float
static final float
static final float
static final float
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int[]
static final int[]
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final String
VIEW_LOG_TAG = "View"
static final int
static final int[]
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
From android.view.ViewGroup
static final int
static final int
static final int
static final int
static final int
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

Inherited methods

From android.widget.FrameLayout
boolean
FrameLayout.LayoutParams
FrameLayout.LayoutParams
CharSequence
boolean

This method is deprecated.

boolean
void
onLayout(boolean changed, int left, int top, int right, int bottom)
void
onMeasure(int widthMeasureSpec, int heightMeasureSpec)
void
setForegroundGravity(int foregroundGravity)
void
setMeasureAllChildren(boolean measureAll)
boolean
From androidx.leanback.widget.picker.Picker
void

Register a callback to be invoked when the picker's value has changed.

boolean
float

Returns number of visible items showing in a column when it's activated.

@Nullable PickerColumn
getColumnAt(int colIndex)

Get nth PickerColumn.

int

Get number of PickerColumns.

int

Classes extending Picker can choose to override this method to supply the Picker's column's single item height in pixels.

final @LayoutRes int

Classes extending Picker can call setPickerItemLayoutId to supply the Picker's item's layout id

final @IdRes int

Returns the Picker's item's TextView's id from within the layout provided by getPickerItemLayoutId or 0 if the layout provided by getPickerItemLayoutId is a {link TextView}.

int

Get current activated column index.

final CharSequence

This method is deprecated.

Use getSeparators

final @NonNull List<CharSequence>

Returns the list of separators that will be populated between the picker column fields.

float

Returns number of visible items showing in a column when it's not activated.

boolean
onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect)
void

Remove a previously installed value changed callback

void
requestChildFocus(View child, View focused)
void
setActivated(boolean activated)
void
setActivatedVisibleItemCount(float visiblePickerItems)

Changes number of visible items showing in a column when it's activated.

void
setColumnAt(int columnIndex, @NonNull PickerColumn column)

When column labels change or column range changes, call this function to re-populate the selection list.

void
setColumnValue(int columnIndex, int value, boolean runAnimation)

Manually set current value of a column.

void

Set columns and create Views.

final void
setPickerItemLayoutId(@LayoutRes int pickerItemLayoutId)

Sets the layout to use for picker items.

final void
setPickerItemTextViewId(@IdRes int textViewId)

Sets the Picker's item's TextView's id from within the layout provided by getPickerItemLayoutId or 0 if the layout provided by getPickerItemLayoutId is a {link TextView}.

void
setSelectedColumn(int columnIndex)

Change current selected column.

final void

Sets separator String between Picker columns.

final void

Sets the list of separators that will be populated between the Picker columns.

void
setVisibleItemCount(float pickerItems)

Changes number of visible items showing in a column when it's not activated.

From android.view.View