public class DatePickerDialog extends AppCompatDialogFragment implements android.view.View.OnClickListener, DatePickerController
| Modifier and Type | Class and Description |
|---|---|
protected static interface |
DatePickerDialog.OnDateChangedListener
The callback used to notify other date picker components of a change in selected date.
|
static interface |
DatePickerDialog.OnDateSetListener
The callback used to indicate the user is done filling in the date.
|
static class |
DatePickerDialog.ScrollOrientation |
static class |
DatePickerDialog.Version |
| Constructor and Description |
|---|
DatePickerDialog() |
| Modifier and Type | Method and Description |
|---|---|
void |
autoDismiss(boolean autoDismiss)
Set whether the picker should dismiss itself when a day is selected
|
void |
dismissOnPause(boolean dismissOnPause)
Set whether the picker should dismiss itself when being paused or whether it should try to survive an orientation change
|
int |
getAccentColor()
Get the accent color of this dialog
|
java.util.Calendar[] |
getDisabledDays() |
java.util.Calendar |
getEndDate() |
int |
getFirstDayOfWeek() |
java.util.Calendar[] |
getHighlightedDays() |
java.util.Locale |
getLocale()
Return the current locale (default or other)
|
java.util.Calendar |
getMaxDate() |
int |
getMaxYear() |
java.util.Calendar |
getMinDate() |
int |
getMinYear() |
DatePickerDialog.OnDateSetListener |
getOnDateSetListener()
Get a reference to the callback
|
DatePickerDialog.ScrollOrientation |
getScrollOrientation()
Get which way the user needs to swipe to switch months in the MonthView
|
java.util.Calendar[] |
getSelectableDays() |
MonthAdapter.CalendarDay |
getSelectedDay() |
java.util.Calendar |
getStartDate() |
java.util.TimeZone |
getTimeZone() |
DatePickerDialog.Version |
getVersion()
Get the layout version the Dialog is using
|
void |
initialize(DatePickerDialog.OnDateSetListener callBack,
java.util.Calendar initialSelection) |
void |
initialize(DatePickerDialog.OnDateSetListener callBack,
int year,
int monthOfYear,
int dayOfMonth) |
boolean |
isHighlighted(int year,
int month,
int day) |
boolean |
isOutOfRange(int year,
int month,
int day) |
boolean |
isThemeDark()
Returns true when the dark theme should be used
|
static DatePickerDialog |
newInstance(DatePickerDialog.OnDateSetListener callback)
Create a new DatePickerDialog instance initialised to the current system date.
|
static DatePickerDialog |
newInstance(DatePickerDialog.OnDateSetListener callback,
java.util.Calendar initialSelection)
Create a new DatePickerDialog instance with a specific initial selection.
|
static DatePickerDialog |
newInstance(DatePickerDialog.OnDateSetListener callBack,
int year,
int monthOfYear,
int dayOfMonth)
Create a new DatePickerDialog instance with a specific initial selection.
|
void |
notifyOnDateListener() |
void |
onCancel(android.content.DialogInterface dialog) |
void |
onClick(android.view.View v) |
void |
onConfigurationChanged(android.content.res.Configuration newConfig) |
void |
onCreate(android.os.Bundle savedInstanceState) |
android.view.View |
onCreateView(android.view.LayoutInflater inflater,
android.view.ViewGroup container,
android.os.Bundle savedInstanceState) |
void |
onDayOfMonthSelected(int year,
int month,
int day) |
void |
onDismiss(android.content.DialogInterface dialog) |
void |
onPause() |
void |
onResume() |
void |
onSaveInstanceState(android.os.Bundle outState) |
void |
onYearSelected(int year) |
void |
registerOnDateChangedListener(DatePickerDialog.OnDateChangedListener listener) |
void |
setAccentColor(int color)
Set the accent color of this dialog
|
void |
setAccentColor(java.lang.String color)
Set the accent color of this dialog
|
void |
setCancelColor(int color)
Set the text color of the Cancel button
|
void |
setCancelColor(java.lang.String color)
Set the text color of the Cancel button
|
void |
setCancelText(int cancelResid)
Set the label for the Cancel button (max 12 characters)
|
void |
setCancelText(java.lang.String cancelString)
Set the label for the Cancel button (max 12 characters)
|
void |
setDateRangeLimiter(DateRangeLimiter dateRangeLimiter)
Provide a DateRangeLimiter for full control over which dates are enabled and disabled in the picker
|
void |
setDisabledDays(java.util.Calendar[] disabledDays)
Sets a list of days that are not selectable in the picker
Setting this value will take precedence over using setMinDate() and setMaxDate(), but stacks with setSelectableDays()
|
void |
setFirstDayOfWeek(int startOfWeek) |
void |
setHighlightedDays(java.util.Calendar[] highlightedDays)
Sets an array of dates which should be highlighted when the picker is drawn
|
void |
setLocale(java.util.Locale locale)
Set a custom locale to be used when generating various strings in the picker
|
void |
setMaxDate(java.util.Calendar calendar)
Sets the minimal date supported by this DatePicker.
|
void |
setMinDate(java.util.Calendar calendar)
Sets the minimal date supported by this DatePicker.
|
void |
setOkColor(int color)
Set the text color of the OK button
|
void |
setOkColor(java.lang.String color)
Set the text color of the OK button
|
void |
setOkText(int okResid)
Set the label for the Ok button (max 12 characters)
|
void |
setOkText(java.lang.String okString)
Set the label for the Ok button (max 12 characters)
|
void |
setOnCancelListener(android.content.DialogInterface.OnCancelListener onCancelListener) |
void |
setOnDateSetListener(DatePickerDialog.OnDateSetListener listener) |
void |
setOnDismissListener(android.content.DialogInterface.OnDismissListener onDismissListener) |
void |
setScrollOrientation(DatePickerDialog.ScrollOrientation orientation)
Set which way the user needs to swipe to switch months in the MonthView
|
void |
setSelectableDays(java.util.Calendar[] selectableDays)
Sets a list of days which are the only valid selections.
|
void |
setThemeDark(boolean themeDark)
Set whether the dark theme should be used
|
void |
setTimeZone(java.util.TimeZone timeZone)
Deprecated.
|
void |
setTitle(java.lang.String title)
Set a title to be displayed instead of the weekday
|
void |
setVersion(DatePickerDialog.Version version)
Set which layout version the picker should use
|
void |
setYearRange(int startYear,
int endYear) |
void |
showYearPickerFirst(boolean yearPicker)
Set whether the year picker of the month and day picker is shown first
|
void |
tryVibrate() |
void |
unregisterOnDateChangedListener(DatePickerDialog.OnDateChangedListener listener) |
void |
vibrate(boolean vibrate)
Set whether the device should vibrate when touching fields
|
public static DatePickerDialog newInstance(DatePickerDialog.OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth)
callBack - How the parent is notified that the date is set.year - The initial year of the dialog.monthOfYear - The initial month of the dialog.dayOfMonth - The initial day of the dialog.public static DatePickerDialog newInstance(DatePickerDialog.OnDateSetListener callback)
callback - How the parent is notified that the date is set.public static DatePickerDialog newInstance(DatePickerDialog.OnDateSetListener callback, java.util.Calendar initialSelection)
callback - How the parent is notified that the date is set.initialSelection - A Calendar object containing the original selection of the picker.
(Time is ignored by trimming the Calendar to midnight in the current
TimeZone of the Calendar object)public void initialize(DatePickerDialog.OnDateSetListener callBack, java.util.Calendar initialSelection)
public void initialize(DatePickerDialog.OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth)
public void onCreate(android.os.Bundle savedInstanceState)
public void onSaveInstanceState(android.os.Bundle outState)
public android.view.View onCreateView(android.view.LayoutInflater inflater,
android.view.ViewGroup container,
android.os.Bundle savedInstanceState)
public void onConfigurationChanged(android.content.res.Configuration newConfig)
public void onResume()
public void onPause()
public void onCancel(android.content.DialogInterface dialog)
public void onDismiss(android.content.DialogInterface dialog)
public void vibrate(boolean vibrate)
vibrate - true if the device should vibrate when touching a fieldpublic void dismissOnPause(boolean dismissOnPause)
dismissOnPause - true if the dialog should dismiss itself when it's pausingpublic void autoDismiss(boolean autoDismiss)
autoDismiss - true if the dialog should dismiss itself when a day is selectedpublic void setThemeDark(boolean themeDark)
themeDark - true if the dark theme should be used, false if the default theme should be usedpublic boolean isThemeDark()
isThemeDark in interface DatePickerControllerpublic void setAccentColor(java.lang.String color)
color - the accent color you wantpublic void setAccentColor(int color)
color - the accent color you wantpublic void setOkColor(java.lang.String color)
color - the color you wantpublic void setOkColor(int color)
color - the color you wantpublic void setCancelColor(java.lang.String color)
color - the color you wantpublic void setCancelColor(int color)
color - the color you wantpublic int getAccentColor()
getAccentColor in interface DatePickerControllerpublic void showYearPickerFirst(boolean yearPicker)
yearPicker - booleanpublic void setFirstDayOfWeek(int startOfWeek)
public void setYearRange(int startYear,
int endYear)
public void setMinDate(java.util.Calendar calendar)
calendar - a Calendar object set to the year, month, day desired as the mindate.public java.util.Calendar getMinDate()
public void setMaxDate(java.util.Calendar calendar)
calendar - a Calendar object set to the year, month, day desired as the maxdate.public java.util.Calendar getMaxDate()
public void setHighlightedDays(java.util.Calendar[] highlightedDays)
highlightedDays - an Array of Calendar objects containing the dates to be highlightedpublic java.util.Calendar[] getHighlightedDays()
public boolean isHighlighted(int year,
int month,
int day)
isHighlighted in interface DatePickerControllerpublic void setSelectableDays(java.util.Calendar[] selectableDays)
selectableDays - an Array of Calendar Objects containing the selectable datespublic java.util.Calendar[] getSelectableDays()
public void setDisabledDays(java.util.Calendar[] disabledDays)
disabledDays - an Array of Calendar Objects containing the disabled datespublic java.util.Calendar[] getDisabledDays()
public void setDateRangeLimiter(DateRangeLimiter dateRangeLimiter)
dateRangeLimiter - An implementation of the DateRangeLimiter interfacepublic void setTitle(java.lang.String title)
title - String - The title to be displayedpublic void setOkText(java.lang.String okString)
okString - A literal String to be used as the Ok button labelpublic void setOkText(int okResid)
okResid - A resource ID to be used as the Ok button labelpublic void setCancelText(java.lang.String cancelString)
cancelString - A literal String to be used as the Cancel button labelpublic void setCancelText(int cancelResid)
cancelResid - A resource ID to be used as the Cancel button labelpublic void setVersion(DatePickerDialog.Version version)
version - The version to usepublic DatePickerDialog.Version getVersion()
getVersion in interface DatePickerControllerpublic void setScrollOrientation(DatePickerDialog.ScrollOrientation orientation)
orientation - The orientation to usepublic DatePickerDialog.ScrollOrientation getScrollOrientation()
getScrollOrientation in interface DatePickerController@Deprecated public void setTimeZone(java.util.TimeZone timeZone)
timeZone - The timezone to usepublic void setLocale(java.util.Locale locale)
locale - Localepublic java.util.Locale getLocale()
getLocale in interface DatePickerControllerpublic void setOnDateSetListener(DatePickerDialog.OnDateSetListener listener)
public void setOnCancelListener(android.content.DialogInterface.OnCancelListener onCancelListener)
public void setOnDismissListener(android.content.DialogInterface.OnDismissListener onDismissListener)
public DatePickerDialog.OnDateSetListener getOnDateSetListener()
public void onClick(android.view.View v)
onClick in interface android.view.View.OnClickListenerpublic void onYearSelected(int year)
onYearSelected in interface DatePickerControllerpublic void onDayOfMonthSelected(int year,
int month,
int day)
onDayOfMonthSelected in interface DatePickerControllerpublic MonthAdapter.CalendarDay getSelectedDay()
getSelectedDay in interface DatePickerControllerpublic java.util.Calendar getStartDate()
getStartDate in interface DatePickerControllerpublic java.util.Calendar getEndDate()
getEndDate in interface DatePickerControllerpublic int getMinYear()
getMinYear in interface DatePickerControllerpublic int getMaxYear()
getMaxYear in interface DatePickerControllerpublic boolean isOutOfRange(int year,
int month,
int day)
isOutOfRange in interface DatePickerControllerpublic int getFirstDayOfWeek()
getFirstDayOfWeek in interface DatePickerControllerpublic void registerOnDateChangedListener(DatePickerDialog.OnDateChangedListener listener)
registerOnDateChangedListener in interface DatePickerControllerpublic void unregisterOnDateChangedListener(DatePickerDialog.OnDateChangedListener listener)
unregisterOnDateChangedListener in interface DatePickerControllerpublic void tryVibrate()
tryVibrate in interface DatePickerControllerpublic java.util.TimeZone getTimeZone()
getTimeZone in interface DatePickerControllerpublic void notifyOnDateListener()