Google は、黒人コミュニティに対する人種平等の促進に取り組んでいます。取り組みを見る

TimePicker

public class TimePicker
extends Picker

java.lang.Object
   ↳ 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

Summary

Inherited constants

Inherited fields

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 getHour()

Returns the currently selected hour using 24-hour time.

int getMinute()

Returns the currently selected minute.

boolean is24Hour()
boolean isPm()

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(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(int minute)

Sets the currently selected minute.

Inherited methods

Public constructors

TimePicker

public TimePicker (Context context, 
                AttributeSet attrs)

Constructor called when inflating a TimePicker widget. This version uses a default style of 0, so the only attribute values applied are those in the Context's Theme and the given AttributeSet.

Parameters
context Context: the context this TimePicker widget is associated with through which we can access the current theme attributes and resources