public class DatePickerDialog extends AlertDialog implements DialogInterface.OnClickListener, DatePicker.OnDateChangedListener
DatePicker
.
See the Pickers guide.
Modifier and Type | Class and Description |
---|---|
static interface |
DatePickerDialog.OnDateSetListener
The listener used to indicate the user has finished selecting a date.
|
AlertDialog.Builder
DialogInterface.OnCancelListener, DialogInterface.OnClickListener, DialogInterface.OnDismissListener, DialogInterface.OnKeyListener, DialogInterface.OnMultiChoiceClickListener, DialogInterface.OnShowListener
LAYOUT_HINT_NONE, LAYOUT_HINT_SIDE, THEME_DEVICE_DEFAULT_DARK, THEME_DEVICE_DEFAULT_LIGHT, THEME_HOLO_DARK, THEME_HOLO_LIGHT, THEME_TRADITIONAL
mCancelable
BUTTON_NEGATIVE, BUTTON_NEUTRAL, BUTTON_POSITIVE, BUTTON1, BUTTON2, BUTTON3
Constructor and Description |
---|
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,
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)
Creates a new date picker dialog for the current date.
|
DatePickerDialog(Context context,
int themeResId,
DatePickerDialog.OnDateSetListener listener,
int year,
int monthOfYear,
int dayOfMonth)
Creates a new date picker dialog for the specified date.
|
Modifier and Type | Method and Description |
---|---|
DatePicker |
getDatePicker()
Returns the
DatePicker contained in this dialog. |
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.
|
getButton, getListView, onCreate, onKeyDown, onKeyUp, setButton, setButton, setButton, setButton, setButton2, setButton2, setButton3, setButton3, setCustomTitle, setIcon, setIcon, setIconAttribute, setInverseBackgroundForced, setMessage, setTitle, setView, setView
addContentView, cancel, closeOptionsMenu, create, dismiss, dispatchGenericMotionEvent, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, findViewById, getActionBar, getContext, getCurrentFocus, getLayoutInflater, getOwnerActivity, getSearchEvent, getVolumeControlStream, getWindow, hide, invalidateOptionsMenu, isShowing, onActionModeFinished, onActionModeStarted, onAttachedToWindow, onBackPressed, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreateContextMenu, onCreateOptionsMenu, onCreatePanelMenu, onCreatePanelView, onDetachedFromWindow, onGenericMotionEvent, onKeyLongPress, onKeyMultiple, onKeyShortcut, onMenuItemSelected, onMenuOpened, onOptionsItemSelected, onOptionsMenuClosed, onPanelClosed, onPrepareOptionsMenu, onPreparePanel, onSearchRequested, onSearchRequested, onStart, onStop, onTouchEvent, onTrackballEvent, onWindowAttributesChanged, onWindowDismissed, onWindowFocusChanged, onWindowStartingActionMode, onWindowStartingActionMode, openContextMenu, openOptionsMenu, registerForContextMenu, requestWindowFeature, setCancelable, setCanceledOnTouchOutside, setCancelMessage, setContentView, setContentView, setContentView, setDismissMessage, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setOnCancelListener, setOnDismissListener, setOnKeyListener, setOnShowListener, setOwnerActivity, setTitle, setVolumeControlStream, show, takeCancelAndDismissListeners, takeKeyEvents, unregisterForContextMenu
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
cancel, dismiss
onProvideKeyboardShortcuts
public DatePickerDialog(Context context)
context
- the parent contextpublic DatePickerDialog(Context context, @StyleRes int themeResId)
context
- the parent contextthemeResId
- the resource ID of the theme against which to inflate
this dialog, or 0
to use the parent
context
's default alert dialog themepublic DatePickerDialog(Context context, DatePickerDialog.OnDateSetListener listener, int year, int month, int dayOfMonth)
context
- the parent contextlistener
- the listener to call when the user sets the dateyear
- the initially selected yearmonth
- the initially selected month (0-11 for compatibility with
Calendar.MONTH
)dayOfMonth
- the initially selected day of month (1-31, depending
on month)public DatePickerDialog(Context context, @StyleRes int themeResId, DatePickerDialog.OnDateSetListener listener, int year, int monthOfYear, int dayOfMonth)
context
- the parent contextthemeResId
- the resource ID of the theme against which to inflate
this dialog, or 0
to use the parent
context
's default alert dialog themelistener
- the listener to call when the user sets the dateyear
- the initially selected yearmonthOfYear
- the initially selected month of the year (0-11 for
compatibility with Calendar.MONTH
)dayOfMonth
- the initially selected day of month (1-31, depending
on month)public void onDateChanged(DatePicker view, int year, int month, int dayOfMonth)
DatePicker.OnDateChangedListener
onDateChanged
in interface DatePicker.OnDateChangedListener
view
- The view associated with this listener.year
- The year that was set.month
- The month that was set (0-11) for compatibility
with Calendar
.dayOfMonth
- The day of the month that was set.public void setOnDateSetListener(DatePickerDialog.OnDateSetListener listener)
listener
- the listener to call when the user sets the datepublic void onClick(DialogInterface dialog, int which)
DialogInterface.OnClickListener
onClick
in interface DialogInterface.OnClickListener
dialog
- The dialog that received the click.which
- The button that was clicked (e.g.
DialogInterface.BUTTON1
) or the position
of the item clicked.public DatePicker getDatePicker()
DatePicker
contained in this dialog.public void updateDate(int year, int month, int dayOfMonth)
year
- the yearmonth
- the month (0-11 for compatibility with
Calendar.MONTH
)dayOfMonth
- the day of month (1-31, depending on month)public Bundle onSaveInstanceState()
Dialog
onSaveInstanceState
in class Dialog
public void onRestoreInstanceState(Bundle savedInstanceState)
Dialog
Dialog.onSaveInstanceState()
,
so be sure to call through to super when overriding unless you want to
do all restoring of state yourself.onRestoreInstanceState
in class Dialog
savedInstanceState
- The state of the dialog previously saved by
Dialog.onSaveInstanceState()
.