public class

DatePicker

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

Class Overview

A view for selecting a month / year / day based on a calendar like layout. For a dialog using this view, see DatePickerDialog.

Summary

Nested Classes
public class DatePicker.OnDateChangedListener The callback used to indicate the user changes the date. 
[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
Public Constructors
DatePicker(Context context)
DatePicker(Context context, AttributeSet attrs)
DatePicker(Context context, AttributeSet attrs, int defStyle)
Public Methods
int getDayOfMonth()
int getMonth()
int getYear()
void init(int year, int monthOfYear, int dayOfMonth, DatePicker.OnDateChangedListener onDateChangedListener)
Initialize the state.
void setEnabled(boolean enabled)
Set the enabled state of this view.
void updateDate(int year, int monthOfYear, int dayOfMonth)
Protected Methods
void dispatchRestoreInstanceState(SparseArray<Parcelable> container)
Override so we are in complete control of save / restore for this widget.
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

Public Constructors

public DatePicker (Context context)

public DatePicker (Context context, AttributeSet attrs)

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

Public Methods

public int getDayOfMonth ()

public int getMonth ()

public int getYear ()

public void init (int year, int monthOfYear, int dayOfMonth, DatePicker.OnDateChangedListener onDateChangedListener)

Initialize the state.

Parameters
year The initial year.
monthOfYear The initial month.
dayOfMonth The initial day of the month.
onDateChangedListener How user is notified date is changed by user, can be null.

public void setEnabled (boolean enabled)

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 updateDate (int year, int monthOfYear, int dayOfMonth)

Protected Methods

protected void dispatchRestoreInstanceState (SparseArray<Parcelable> container)

Override so we are in complete control of save / restore for this widget.

Parameters
container The SparseArray which holds previously saved state.

protected void onRestoreInstanceState (Parcelable state)

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

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.