public class

TimePicker

extends FrameLayout
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ android.widget.TimePicker

Class Overview

A view for selecting the time of day, in either 24 hour or AM/PM mode. The hour, each minute digit, and AM/PM (if applicable) can be conrolled by vertical spinners. The hour can be entered by keyboard input. Entering in two digit hours can be accomplished by hitting two digits within a timeout of about a second (e.g. '1' then '2' to select 12). The minutes can be entered by entering single digits. Under AM/PM mode, the user can hit 'a', 'A", 'p' or 'P' to pick. For a dialog using this view, see TimePickerDialog.

See the Time Picker tutorial.

Summary

Nested Classes
interface TimePicker.OnTimeChangedListener The callback interface used to indicate the time has been adjusted. 
[Expand]
Inherited XML Attributes
From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
TimePicker(Context context)
TimePicker(Context context, AttributeSet attrs)
TimePicker(Context context, AttributeSet attrs, int defStyle)
Public Methods
boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event)
Dispatches an AccessibilityEvent to the View children to be populated.
int getBaseline()

Return the offset of the widget's text baseline from the widget's top boundary.

Integer getCurrentHour()
Integer getCurrentMinute()
boolean is24HourView()
boolean isEnabled()
Returns the enabled status for this view.
void setCurrentHour(Integer currentHour)
Set the current hour.
void setCurrentMinute(Integer currentMinute)
Set the current minute (0-59).
void setEnabled(boolean enabled)
Set the enabled state of this view.
void setIs24HourView(Boolean is24HourView)
Set whether in 24 hour or AM/PM mode.
void setOnTimeChangedListener(TimePicker.OnTimeChangedListener onTimeChangedListener)
Set the callback that indicates the time has been adjusted by the user.
Protected Methods
void onRestoreInstanceState(Parcelable state)
Hook allowing a view to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState().
Parcelable onSaveInstanceState()
Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state.
[Expand]
Inherited Methods
From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource

Public Constructors

public TimePicker (Context context)

Since: API Level 1

public TimePicker (Context context, AttributeSet attrs)

Since: API Level 1

public TimePicker (Context context, AttributeSet attrs, int defStyle)

Since: API Level 1

Public Methods

public boolean dispatchPopulateAccessibilityEvent (AccessibilityEvent event)

Since: API Level 4

Dispatches an AccessibilityEvent to the View children to be populated.

Parameters
event The event.
Returns
  • True if the event population was completed.

public int getBaseline ()

Since: API Level 1

Return the offset of the widget's text baseline from the widget's top boundary. If this widget does not support baseline alignment, this method returns -1.

Returns
  • the offset of the baseline within the widget's bounds or -1 if baseline alignment is not supported

public Integer getCurrentHour ()

Since: API Level 1

Returns
  • The current hour in the range (0-23).

public Integer getCurrentMinute ()

Since: API Level 1

Returns
  • The current minute.

public boolean is24HourView ()

Since: API Level 1

Returns
  • true if this is in 24 hour view else false.

public boolean isEnabled ()

Since: API Level 1

Returns the enabled status for this view. The interpretation of the enabled state varies by subclass.

Returns
  • True if this view is enabled, false otherwise.

public void setCurrentHour (Integer currentHour)

Since: API Level 1

Set the current hour.

public void setCurrentMinute (Integer currentMinute)

Since: API Level 1

Set the current minute (0-59).

public void setEnabled (boolean enabled)

Since: API Level 1

Set the enabled state of this view. The interpretation of the enabled state varies by subclass.

Parameters
enabled True if this view is enabled, false otherwise.

public void setIs24HourView (Boolean is24HourView)

Since: API Level 1

Set whether in 24 hour or AM/PM mode.

Parameters
is24HourView True = 24 hour mode. False = AM/PM.

public void setOnTimeChangedListener (TimePicker.OnTimeChangedListener onTimeChangedListener)

Since: API Level 1

Set the callback that indicates the time has been adjusted by the user.

Parameters
onTimeChangedListener the callback, should not be null.

Protected Methods

protected void onRestoreInstanceState (Parcelable state)

Since: API Level 1

Hook allowing a view to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState(). This function will never be called with a null state.

Parameters
state The frozen state that had previously been returned by onSaveInstanceState().

protected Parcelable onSaveInstanceState ()

Since: API Level 1

Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state. This state should only contain information that is not persistent or can not be reconstructed later. For example, you will never store your current position on screen because that will be computed again when a new instance of the view is placed in its view hierarchy.

Some examples of things you may store here: the current cursor position in a text view (but usually not the text itself since that is stored in a content provider or other persistent storage), the currently selected item in a list view.

Returns
  • Returns a Parcelable object containing the view's current dynamic state, or null if there is nothing interesting to save. The default implementation returns null.