public class DatePickerDialog extends DialogFragment implements View.OnClickListener, DatePickerController
Modifier and Type | Class and Description |
---|---|
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.
|
Fragment.InstantiationException, Fragment.SavedState
STYLE_NO_FRAME, STYLE_NO_INPUT, STYLE_NO_TITLE, STYLE_NORMAL
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
Constructor and Description |
---|
DatePickerDialog() |
Modifier and Type | Method and Description |
---|---|
int |
getFirstDayOfWeek() |
Calendar |
getMaxDate() |
int |
getMaxYear() |
Calendar |
getMinDate() |
int |
getMinYear() |
MonthAdapter.CalendarDay |
getSelectedDay() |
void |
initialize(DatePickerDialog.OnDateSetListener callBack,
int year,
int monthOfYear,
int dayOfMonth) |
static DatePickerDialog |
newInstance(DatePickerDialog.OnDateSetListener callBack,
int year,
int monthOfYear,
int dayOfMonth) |
void |
onClick(View v)
Called when a view has been clicked.
|
void |
onCreate(Bundle savedInstanceState)
Called to do initial creation of a fragment.
|
View |
onCreateView(LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState)
Called to have the fragment instantiate its user interface view.
|
void |
onDayOfMonthSelected(int year,
int month,
int day) |
void |
onPause()
Called when the Fragment is no longer resumed.
|
void |
onResume()
Called when the fragment is visible to the user and actively running.
|
void |
onSaveInstanceState(Bundle outState)
Called to ask the fragment to save its current dynamic state, so it
can later be reconstructed in a new instance of its process is
restarted.
|
void |
onYearSelected(int year) |
void |
registerOnDateChangedListener(DatePickerDialog.OnDateChangedListener listener) |
void |
setFirstDayOfWeek(int startOfWeek) |
void |
setMaxDate(Calendar calendar)
Sets the minimal date supported by this DatePicker.
|
void |
setMinDate(Calendar calendar)
Sets the minimal date supported by this DatePicker.
|
void |
setOnDateSetListener(DatePickerDialog.OnDateSetListener listener) |
void |
setYearRange(int startYear,
int endYear) |
void |
tryVibrate() |
void |
unregisterOnDateChangedListener(DatePickerDialog.OnDateChangedListener listener) |
dismiss, dismissAllowingStateLoss, dump, getDialog, getLayoutInflater, getShowsDialog, getTheme, isCancelable, onActivityCreated, onAttach, onCancel, onCreateDialog, onDestroyView, onDetach, onDismiss, onStart, onStop, setCancelable, setShowsDialog, setStyle, show, show, showAllowingStateLoss
equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLoaderManager, getParentFragment, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, hashCode, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isRemoving, isResumed, isVisible, onActivityResult, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroy, onDestroyOptionsMenu, onHiddenChanged, onInflate, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPictureInPictureModeChanged, onPrepareOptionsMenu, onRequestPermissionsResult, onTrimMemory, onViewCreated, onViewStateRestored, registerForContextMenu, requestPermissions, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterSharedElementTransitionCallback, setEnterTransition, setExitSharedElementCallback, setExitSharedElementTransitionCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivity, startActivityForResult, startActivityForResult, startIntentSenderForResult, toString, unregisterForContextMenu
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 void initialize(DatePickerDialog.OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth)
public void onCreate(Bundle savedInstanceState)
Fragment
Fragment.onAttach(Activity)
and before
Fragment.onCreateView(LayoutInflater, ViewGroup, Bundle)
, but is not called if the fragment
instance is retained across Activity re-creation (see Fragment.setRetainInstance(boolean)
).
Note that this can be called while the fragment's activity is
still in the process of being created. As such, you can not rely
on things like the activity's content view hierarchy being initialized
at this point. If you want to do work once the activity itself is
created, see Fragment.onActivityCreated(Bundle)
.
If your app's targetSdkVersion
is Build.VERSION_CODES.M
or lower, child fragments being restored from the savedInstanceState are restored after
onCreate
returns. When targeting Build.VERSION_CODES.N
or
above and running on an N or newer platform version
they are restored by Fragment.onCreate
.
onCreate
in class DialogFragment
savedInstanceState
- If the fragment is being re-created from
a previous saved state, this is the state.public void onSaveInstanceState(Bundle outState)
Fragment
Fragment.onCreate(Bundle)
,
Fragment.onCreateView(LayoutInflater, ViewGroup, Bundle)
, and
Fragment.onActivityCreated(Bundle)
.
This corresponds to Activity.onSaveInstanceState(Bundle)
and most of the discussion there
applies here as well. Note however: this method may be called
at any time before Fragment.onDestroy()
. There are many situations
where a fragment may be mostly torn down (such as when placed on the
back stack with no UI showing), but its state will not be saved until
its owning activity actually needs to save its state.
onSaveInstanceState
in class DialogFragment
outState
- Bundle in which to place your saved state.public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
Fragment
Fragment.onCreate(Bundle)
and Fragment.onActivityCreated(Bundle)
.
If you return a View from here, you will later be called in
Fragment.onDestroyView()
when the view is being released.
onCreateView
in class Fragment
inflater
- The LayoutInflater object that can be used to inflate
any views in the fragment,container
- If non-null, this is the parent view that the fragment's
UI should be attached to. The fragment should not add the view itself,
but this can be used to generate the LayoutParams of the view.savedInstanceState
- If non-null, this fragment is being re-constructed
from a previous saved state as given here.public void onResume()
Fragment
Activity.onResume
of the containing
Activity's lifecycle.public void onPause()
Fragment
Activity.onPause
of the containing
Activity's lifecycle.public void setFirstDayOfWeek(int startOfWeek)
public void setYearRange(int startYear, int endYear)
public void setMinDate(Calendar calendar)
calendar
- a Calendar object set to the year, month, day desired as the mindate.public Calendar getMinDate()
getMinDate
in interface DatePickerController
public void setMaxDate(Calendar calendar)
calendar
- a Calendar object set to the year, month, day desired as the maxdate.public Calendar getMaxDate()
getMaxDate
in interface DatePickerController
public void setOnDateSetListener(DatePickerDialog.OnDateSetListener listener)
public void onClick(View v)
View.OnClickListener
onClick
in interface View.OnClickListener
v
- The view that was clicked.public void onYearSelected(int year)
onYearSelected
in interface DatePickerController
public void onDayOfMonthSelected(int year, int month, int day)
onDayOfMonthSelected
in interface DatePickerController
public MonthAdapter.CalendarDay getSelectedDay()
getSelectedDay
in interface DatePickerController
public int getMinYear()
getMinYear
in interface DatePickerController
public int getMaxYear()
getMaxYear
in interface DatePickerController
public int getFirstDayOfWeek()
getFirstDayOfWeek
in interface DatePickerController
public void registerOnDateChangedListener(DatePickerDialog.OnDateChangedListener listener)
registerOnDateChangedListener
in interface DatePickerController
public void unregisterOnDateChangedListener(DatePickerDialog.OnDateChangedListener listener)
unregisterOnDateChangedListener
in interface DatePickerController
public void tryVibrate()
tryVibrate
in interface DatePickerController