DatePickerDialog
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.
Summary
Nested classes | |
|---|---|
interface |
DatePickerDialog.OnDateSetListener
The listener used to indicate the user has finished selecting a date. |
Inherited constants |
|---|
android.app.AlertDialog
|
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 | |
|---|---|
android.app.AlertDialog
| |
android.app.Dialog
| |
java.lang.Object
| |
android.content.DialogInterface
| |
android.view.Window.Callback
| |
android.view.KeyEvent.Callback
| |
android.view.View.OnCreateContextMenuListener
| |
android.content.DialogInterface.OnClickListener
| |
android.widget.DatePicker.OnDateChangedListener
| |
Public constructors
DatePickerDialog
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
This value must never be |
DatePickerDialog
DatePickerDialog (Context context, int themeResId)
Creates a new date picker dialog for the current date.
| Parameters | |
|---|---|
context |
Context: the parent contextThis value must never be |
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
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 contextThis value must never be |
listener |
DatePickerDialog.OnDateSetListener: the listener to call when the user sets the dateThis value may be |
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
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 contextThis value must never be |
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 dateThis value may be |
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)
|
Public methods
getDatePicker
DatePicker getDatePicker ()
Returns the DatePicker contained in this dialog.
| Returns | |
|---|---|
DatePicker |
the date picker
This value will never be |
onClick
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 clickThis value must never be |
which |
int: the button that was clicked (ex.
BUTTON_POSITIVE) or the position
of the item clicked
|
onDateChanged
void onDateChanged (DatePicker view, int year, int month, int dayOfMonth)
Called upon a date change.
| Parameters | |
|---|---|
view |
DatePicker: The view associated with this listener.This value must never be |
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.
|
onRestoreInstanceState
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().
|
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. |
setOnDateSetListener
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
This value may be |
updateDate
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)
|
Interfaces
- ActionBar.OnMenuVisibilityListener
- ActionBar.OnNavigationListener
- ActionBar.TabListener
- AlarmManager.OnAlarmListener
- Application.ActivityLifecycleCallbacks
- Application.OnProvideAssistDataListener
- AppOpsManager.OnOpChangedListener
- DatePickerDialog.OnDateSetListener
- FragmentBreadCrumbs.OnBreadCrumbClickListener
- FragmentManager.BackStackEntry
- FragmentManager.OnBackStackChangedListener
- KeyguardManager.OnKeyguardExitResult
- LoaderManager.LoaderCallbacks
- Notification.Action.Extender
- Notification.Extender
- PendingIntent.OnFinished
- SearchManager.OnCancelListener
- SearchManager.OnDismissListener
- SharedElementCallback.OnSharedElementsReadyListener
- TimePickerDialog.OnTimeSetListener
- UiAutomation.AccessibilityEventFilter
- UiAutomation.OnAccessibilityEventListener
Classes
- ActionBar
- ActionBar.LayoutParams
- ActionBar.Tab
- Activity
- ActivityGroup
- ActivityManager
- ActivityManager.AppTask
- ActivityManager.MemoryInfo
- ActivityManager.ProcessErrorStateInfo
- ActivityManager.RecentTaskInfo
- ActivityManager.RunningAppProcessInfo
- ActivityManager.RunningServiceInfo
- ActivityManager.RunningTaskInfo
- ActivityManager.TaskDescription
- ActivityOptions
- AlarmManager
- AlarmManager.AlarmClockInfo
- AlertDialog
- AlertDialog.Builder
- AliasActivity
- Application
- ApplicationErrorReport
- ApplicationErrorReport.AnrInfo
- ApplicationErrorReport.BatteryInfo
- ApplicationErrorReport.CrashInfo
- ApplicationErrorReport.RunningServiceInfo
- AppOpsManager
- AutomaticZenRule
- DatePickerDialog
- Dialog
- DialogFragment
- DownloadManager
- DownloadManager.Query
- DownloadManager.Request
- ExpandableListActivity
- Fragment
- Fragment.SavedState
- FragmentBreadCrumbs
- FragmentContainer
- FragmentController
- FragmentHostCallback
- FragmentManager
- FragmentManager.FragmentLifecycleCallbacks
- FragmentManagerNonConfig
- FragmentTransaction
- Instrumentation
- Instrumentation.ActivityMonitor
- Instrumentation.ActivityResult
- IntentService
- KeyguardManager
- KeyguardManager.KeyguardDismissCallback
- KeyguardManager.KeyguardLock
- LauncherActivity
- LauncherActivity.IconResizer
- LauncherActivity.ListItem
- ListActivity
- ListFragment
- LoaderManager
- LocalActivityManager
- MediaRouteActionProvider
- MediaRouteButton
- NativeActivity
- Notification
- Notification.Action
- Notification.Action.Builder
- Notification.Action.WearableExtender
- Notification.BigPictureStyle
- Notification.BigTextStyle
- Notification.Builder
- Notification.CarExtender
- Notification.CarExtender.Builder
- Notification.CarExtender.UnreadConversation
- Notification.DecoratedCustomViewStyle
- Notification.DecoratedMediaCustomViewStyle
- Notification.InboxStyle
- Notification.MediaStyle
- Notification.MessagingStyle
- Notification.MessagingStyle.Message
- Notification.Style
- Notification.WearableExtender
- NotificationChannel
- NotificationChannelGroup
- NotificationManager
- NotificationManager.Policy
- PendingIntent
- PictureInPictureParams
- PictureInPictureParams.Builder
- Presentation
- ProgressDialog
- RemoteAction
- RemoteInput
- RemoteInput.Builder
- SearchableInfo
- SearchManager
- Service
- SharedElementCallback
- TabActivity
- TaskStackBuilder
- TimePickerDialog
- UiAutomation
- UiModeManager
- VoiceInteractor
- VoiceInteractor.AbortVoiceRequest
- VoiceInteractor.CommandRequest
- VoiceInteractor.CompleteVoiceRequest
- VoiceInteractor.ConfirmationRequest
- VoiceInteractor.PickOptionRequest
- VoiceInteractor.PickOptionRequest.Option
- VoiceInteractor.Prompt
- VoiceInteractor.Request
- WallpaperInfo
- WallpaperManager
Exceptions