public
class
DatePickerDialog
extends AlertDialog
implements
DialogInterface.OnClickListener,
DatePicker.OnDateChangedListener
java.lang.Object | |||
↳ | android.app.Dialog | ||
↳ | android.app.AlertDialog | ||
↳ | android.app.DatePickerDialog |
A simple dialog containing an DatePicker
.
See the Pickers guide.
Nested classes | |
---|---|
interface |
DatePickerDialog.OnDateSetListener
The listener used to indicate the user has finished selecting a date. |
Inherited constants |
---|
From
class
android.app.AlertDialog
|
From
interface
android.content.DialogInterface
|
Public constructors | |
---|---|
DatePickerDialog(Context context)
Creates a new date picker dialog for the current date using the parent context's default date picker dialog theme. |
|
DatePickerDialog(Context context, int themeResId)
Creates a new date picker dialog for the current date. |
|
DatePickerDialog(Context context, DatePickerDialog.OnDateSetListener listener, int year, int month, int dayOfMonth)
Creates a new date picker dialog for the specified date using the parent context's default date picker dialog theme. |
|
DatePickerDialog(Context context, int themeResId, DatePickerDialog.OnDateSetListener listener, int year, int monthOfYear, int dayOfMonth)
Creates a new date picker dialog for the specified date. |
Public methods | |
---|---|
DatePicker
|
getDatePicker()
Returns the |
void
|
onClick(DialogInterface dialog, int which)
This method will be invoked when a button in the dialog is clicked. |
void
|
onDateChanged(DatePicker view, int year, int month, int dayOfMonth)
Called upon a date change. |
void
|
onRestoreInstanceState(Bundle savedInstanceState)
Restore the state of the dialog from a previously saved bundle. |
Bundle
|
onSaveInstanceState()
Saves the state of the dialog into a bundle. |
void
|
setOnDateSetListener(DatePickerDialog.OnDateSetListener listener)
Sets the listener to call when the user sets the date. |
void
|
updateDate(int year, int month, int dayOfMonth)
Sets the current date. |
Inherited methods | |
---|---|
From
class
android.app.AlertDialog
| |
From
class
android.app.Dialog
| |
From
class
java.lang.Object
| |
From
interface
android.content.DialogInterface
| |
From
interface
android.view.Window.Callback
| |
From
interface
android.view.KeyEvent.Callback
| |
From
interface
android.view.View.OnCreateContextMenuListener
| |
From
interface
android.content.DialogInterface.OnClickListener
| |
From
interface
android.widget.DatePicker.OnDateChangedListener
|
DatePickerDialog (Context context)
Creates a new date picker dialog for the current date using the parent context's default date picker dialog theme.
Parameters | |
---|---|
context |
Context :
the parent context
|
DatePickerDialog (Context context, int themeResId)
Creates a new date picker dialog for the current date.
Parameters | |
---|---|
context |
Context :
the parent context |
themeResId |
int :
the resource ID of the theme against which to inflate
this dialog, or 0 to use the parent
context 's default alert dialog theme
|
DatePickerDialog (Context context, DatePickerDialog.OnDateSetListener listener, int year, int month, int dayOfMonth)
Creates a new date picker dialog for the specified date using the parent context's default date picker dialog theme.
Parameters | |
---|---|
context |
Context :
the parent context |
listener |
DatePickerDialog.OnDateSetListener :
the listener to call when the user sets the date |
year |
int :
the initially selected year |
month |
int :
the initially selected month (0-11 for compatibility with
MONTH ) |
dayOfMonth |
int :
the initially selected day of month (1-31, depending
on month)
|
DatePickerDialog (Context context, int themeResId, DatePickerDialog.OnDateSetListener listener, int year, int monthOfYear, int dayOfMonth)
Creates a new date picker dialog for the specified date.
Parameters | |
---|---|
context |
Context :
the parent context |
themeResId |
int :
the resource ID of the theme against which to inflate
this dialog, or 0 to use the parent
context 's default alert dialog theme |
listener |
DatePickerDialog.OnDateSetListener :
the listener to call when the user sets the date |
year |
int :
the initially selected year |
monthOfYear |
int :
the initially selected month of the year (0-11 for
compatibility with MONTH ) |
dayOfMonth |
int :
the initially selected day of month (1-31, depending
on month)
|
DatePicker getDatePicker ()
Returns the DatePicker
contained in this dialog.
Returns | |
---|---|
DatePicker |
the date picker |
void onClick (DialogInterface dialog, int which)
This method will be invoked when a button in the dialog is clicked.
Parameters | |
---|---|
dialog |
DialogInterface :
The dialog that received the click. |
which |
int :
The button that was clicked (e.g.
BUTTON1 ) or the position
of the item clicked.
|
void onDateChanged (DatePicker view, int year, int month, int dayOfMonth)
Called upon a date change.
Parameters | |
---|---|
view |
DatePicker :
The view associated with this listener. |
year |
int :
The year that was set. |
month |
int :
The month that was set (0-11) for compatibility
with Calendar . |
dayOfMonth |
int :
The day of the month that was set.
|
void onRestoreInstanceState (Bundle savedInstanceState)
Restore the state of the dialog from a previously saved bundle.
The default implementation restores the state of the dialog's view
hierarchy that was saved in the default implementation of onSaveInstanceState()
,
so be sure to call through to super when overriding unless you want to
do all restoring of state yourself.
Parameters | |
---|---|
savedInstanceState |
Bundle :
The state of the dialog previously saved by
onSaveInstanceState() .
|
Bundle onSaveInstanceState ()
Saves the state of the dialog into a bundle. The default implementation saves the state of its view hierarchy, so you'll likely want to call through to super if you override this to save additional state.
Returns | |
---|---|
Bundle |
A bundle with the state of the dialog. |
void setOnDateSetListener (DatePickerDialog.OnDateSetListener listener)
Sets the listener to call when the user sets the date.
Parameters | |
---|---|
listener |
DatePickerDialog.OnDateSetListener :
the listener to call when the user sets the date
|
void updateDate (int year, int month, int dayOfMonth)
Sets the current date.
Parameters | |
---|---|
year |
int :
the year |
month |
int :
the month (0-11 for compatibility with
MONTH ) |
dayOfMonth |
int :
the day of month (1-31, depending on month)
|