FileDocCategorySizeDatePackage
TimePicker.javaAPI DocAndroid 5.1 API9723Thu Mar 12 22:22:10 GMT 2015android.widget

TimePicker

public class TimePicker extends FrameLayout
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 {@link android.app.TimePickerDialog}.

See the Pickers guide.

Fields Summary
private static final int
MODE_SPINNER
private static final int
MODE_CLOCK
private final TimePickerDelegate
mDelegate
Constructors Summary
public TimePicker(android.content.Context context)


                    
       

                                   
              
    

       
        this(context, null);
    
public TimePicker(android.content.Context context, android.util.AttributeSet attrs)

        this(context, attrs, R.attr.timePickerStyle);
    
public TimePicker(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr)

        this(context, attrs, defStyleAttr, 0);
    
public TimePicker(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr, int defStyleRes)

        super(context, attrs, defStyleAttr, defStyleRes);

        final TypedArray a = context.obtainStyledAttributes(
                attrs, R.styleable.TimePicker, defStyleAttr, defStyleRes);
        final int mode = a.getInt(R.styleable.TimePicker_timePickerMode, MODE_SPINNER);
        a.recycle();

        switch (mode) {
            case MODE_CLOCK:
                mDelegate = new TimePickerClockDelegate(
                        this, context, attrs, defStyleAttr, defStyleRes);
                break;
            case MODE_SPINNER:
            default:
                mDelegate = new TimePickerSpinnerDelegate(
                        this, context, attrs, defStyleAttr, defStyleRes);
                break;
        }
    
Methods Summary
public booleandispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent event)

        return mDelegate.dispatchPopulateAccessibilityEvent(event);
    
public intgetBaseline()

        return mDelegate.getBaseline();
    
public java.lang.IntegergetCurrentHour()

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

        return mDelegate.getCurrentHour();
    
public java.lang.IntegergetCurrentMinute()

return
The current minute.

        return mDelegate.getCurrentMinute();
    
public booleanis24HourView()

return
true if this is in 24 hour view else false.

        return mDelegate.is24HourView();
    
public booleanisEnabled()

        return mDelegate.isEnabled();
    
protected voidonConfigurationChanged(android.content.res.Configuration newConfig)

        super.onConfigurationChanged(newConfig);
        mDelegate.onConfigurationChanged(newConfig);
    
public voidonInitializeAccessibilityEvent(android.view.accessibility.AccessibilityEvent event)

        super.onInitializeAccessibilityEvent(event);
        mDelegate.onInitializeAccessibilityEvent(event);
    
public voidonInitializeAccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo info)

        super.onInitializeAccessibilityNodeInfo(info);
        mDelegate.onInitializeAccessibilityNodeInfo(info);
    
public voidonPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent event)

        super.onPopulateAccessibilityEvent(event);
        mDelegate.onPopulateAccessibilityEvent(event);
    
protected voidonRestoreInstanceState(android.os.Parcelable state)

        BaseSavedState ss = (BaseSavedState) state;
        super.onRestoreInstanceState(ss.getSuperState());
        mDelegate.onRestoreInstanceState(ss);
    
protected android.os.ParcelableonSaveInstanceState()

        Parcelable superState = super.onSaveInstanceState();
        return mDelegate.onSaveInstanceState(superState);
    
public voidsetCurrentHour(java.lang.Integer currentHour)
Set the current hour.

        mDelegate.setCurrentHour(currentHour);
    
public voidsetCurrentMinute(java.lang.Integer currentMinute)
Set the current minute (0-59).

        mDelegate.setCurrentMinute(currentMinute);
    
public voidsetEnabled(boolean enabled)

        super.setEnabled(enabled);
        mDelegate.setEnabled(enabled);
    
public voidsetIs24HourView(java.lang.Boolean is24HourView)
Set whether in 24 hour or AM/PM mode.

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

        mDelegate.setIs24HourView(is24HourView);
    
public voidsetOnTimeChangedListener(android.widget.TimePicker$OnTimeChangedListener onTimeChangedListener)
Set the callback that indicates the time has been adjusted by the user.

param
onTimeChangedListener the callback, should not be null.

        mDelegate.setOnTimeChangedListener(onTimeChangedListener);
    
public voidsetValidationCallback(android.widget.TimePicker$ValidationCallback callback)
Sets the callback that indicates the current time is valid.

param
callback the callback, may be null
hide

        mDelegate.setValidationCallback(callback);