public class TimePickerDialog extends android.app.DialogFragment implements RadialPickerLayout.OnValueSelectedListener
| Modifier and Type | Class and Description |
|---|---|
static interface |
TimePickerDialog.OnTimeSetListener
The callback interface used to indicate the user is done filling in
the time (they clicked on the 'Set' button).
|
static class |
TimePickerDialog.Version |
| Modifier and Type | Field and Description |
|---|---|
static int |
AM |
static int |
HOUR_INDEX |
static int |
MINUTE_INDEX |
static int |
PM |
static int |
SECOND_INDEX |
| Constructor and Description |
|---|
TimePickerDialog() |
| Modifier and Type | Method and Description |
|---|---|
void |
advancePicker(int index) |
void |
dismissOnPause(boolean dismissOnPause)
Set whether the picker should dismiss itself when it's pausing or whether it should try to survive an orientation change
|
void |
enableMinutes(boolean enableMinutes)
Set whether the picker for minutes should be shown
Will disable seconds if minutes are disbled
|
void |
enablePicker() |
void |
enableSeconds(boolean enableSeconds)
Set whether an additional picker for seconds should be shown
Will enable minutes picker as well if seconds picker should be shown
|
int |
getAccentColor() |
TimePickerDialog.OnTimeSetListener |
getOnTimeSetListener()
Get a reference to the OnTimeSetListener callback
|
Timepoint |
getSelectedTime() |
java.lang.String |
getTitle() |
TimePickerDialog.Version |
getVersion() |
void |
initialize(TimePickerDialog.OnTimeSetListener callback,
int hourOfDay,
int minute,
int second,
boolean is24HourMode) |
boolean |
is24HourMode() |
boolean |
isAmDisabled() |
boolean |
isOutOfRange(Timepoint current) |
boolean |
isOutOfRange(Timepoint current,
int index) |
boolean |
isPmDisabled() |
boolean |
isThemeDark() |
static TimePickerDialog |
newInstance(TimePickerDialog.OnTimeSetListener callback,
boolean is24HourMode) |
static TimePickerDialog |
newInstance(TimePickerDialog.OnTimeSetListener callback,
int hourOfDay,
int minute,
boolean is24HourMode) |
static TimePickerDialog |
newInstance(TimePickerDialog.OnTimeSetListener callback,
int hourOfDay,
int minute,
int second,
boolean is24HourMode) |
void |
notifyOnDateListener() |
void |
onCancel(android.content.DialogInterface dialog) |
void |
onConfigurationChanged(android.content.res.Configuration newConfig) |
void |
onCreate(android.os.Bundle savedInstanceState) |
android.app.Dialog |
onCreateDialog(android.os.Bundle savedInstanceState) |
android.view.View |
onCreateView(android.view.LayoutInflater inflater,
android.view.ViewGroup container,
android.os.Bundle savedInstanceState) |
void |
onDismiss(android.content.DialogInterface dialog) |
void |
onPause() |
void |
onResume() |
void |
onSaveInstanceState(android.os.Bundle outState) |
void |
onValueSelected(Timepoint newValue)
Called by the picker for updating the header display.
|
Timepoint |
roundToNearest(Timepoint time,
Timepoint.TYPE type)
Will round the given Timepoint to the nearest valid Timepoint given the following restrictions:
- TYPE.HOUR, it will just round to the next valid point, possible adjusting minutes and seconds
- TYPE.MINUTE, it will round to the next valid point, without adjusting the hour, but possibly adjusting the seconds
- TYPE.SECOND, it will round to the next valid point, only adjusting the seconds
|
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 |
setDisabledTimes(Timepoint[] disabledTimes)
Pass in an array of Timepoints that cannot be selected.
|
void |
setInitialSelection(int hourOfDay,
int minute)
Set the time that will be shown when the picker opens for the first time
Overrides the value given in newInstance
|
void |
setInitialSelection(int hourOfDay,
int minute,
int second)
Set the time that will be shown when the picker opens for the first time
Overrides the value given in newInstance()
|
void |
setInitialSelection(Timepoint time)
Set the time that will be shown when the picker opens for the first time
Overrides the value given in newInstance()
|
void |
setLocale(java.util.Locale locale)
Set the Locale which will be used to generate various strings throughout the picker
|
void |
setMaxTime(int hour,
int minute,
int second) |
void |
setMaxTime(Timepoint maxTime) |
void |
setMinTime(int hour,
int minute,
int second) |
void |
setMinTime(Timepoint minTime) |
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 |
setOnDismissListener(android.content.DialogInterface.OnDismissListener onDismissListener) |
void |
setOnTimeSetListener(TimePickerDialog.OnTimeSetListener callback) |
void |
setSelectableTimes(Timepoint[] selectableTimes)
Pass in an array of Timepoints which are the only possible selections.
|
void |
setStartTime(int hourOfDay,
int minute)
Deprecated.
in favor of
setInitialSelection(int, int) |
void |
setStartTime(int hourOfDay,
int minute,
int second)
Deprecated.
in favor of
setInitialSelection(int, int, int) |
void |
setThemeDark(boolean dark)
Set a dark or light theme.
|
void |
setTimeInterval(int hourInterval)
Set the interval for selectable times in the TimePickerDialog
This is a convenience wrapper around setSelectableTimes
The interval for all three time components can be set independently
If you are not using the seconds / minutes picker, set the respective item to 60 for
better performance.
|
void |
setTimeInterval(int hourInterval,
int minuteInterval)
Set the interval for selectable times in the TimePickerDialog
This is a convenience wrapper around setSelectableTimes
The interval for all three time components can be set independently
If you are not using the seconds / minutes picker, set the respective item to 60 for
better performance.
|
void |
setTimeInterval(int hourInterval,
int minuteInterval,
int secondInterval)
Set the interval for selectable times in the TimePickerDialog
This is a convenience wrapper around
setSelectableTimes(Timepoint[])
The interval for all three time components can be set independently
If you are not using the seconds / minutes picker, set the respective item to 60 for
better performance. |
void |
setTimepointLimiter(TimepointLimiter limiter)
Pass in a custom implementation of TimeLimiter
Disables setSelectableTimes, setDisabledTimes, setTimeInterval, setMinTime and setMaxTime
|
void |
setTitle(java.lang.String title)
Set a title.
|
void |
setVersion(TimePickerDialog.Version version)
Set which layout version the picker should use
|
void |
tryVibrate()
Request the device to vibrate
|
void |
vibrate(boolean vibrate)
Set whether the device should vibrate when touching fields
|
dismiss, dismissAllowingStateLoss, dump, getDialog, getShowsDialog, getTheme, isCancelable, onActivityCreated, onAttach, onDestroyView, onDetach, onStart, onStop, setCancelable, setShowsDialog, setStyle, show, showequals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, 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, isStateSaved, isVisible, onActivityResult, onAttach, onAttachFragment, onContextItemSelected, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroy, onDestroyOptionsMenu, onGetLayoutInflater, onHiddenChanged, onInflate, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPictureInPictureModeChanged, onPictureInPictureModeChanged, onPrepareOptionsMenu, onRequestPermissionsResult, onTrimMemory, onViewCreated, onViewStateRestored, postponeEnterTransition, registerForContextMenu, requestPermissions, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterTransition, setExitSharedElementCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivity, startActivityForResult, startActivityForResult, startIntentSenderForResult, startPostponedEnterTransition, toString, unregisterForContextMenupublic static final int HOUR_INDEX
public static final int MINUTE_INDEX
public static final int SECOND_INDEX
public static final int AM
public static final int PM
public static TimePickerDialog newInstance(TimePickerDialog.OnTimeSetListener callback, int hourOfDay, int minute, int second, boolean is24HourMode)
public static TimePickerDialog newInstance(TimePickerDialog.OnTimeSetListener callback, int hourOfDay, int minute, boolean is24HourMode)
public static TimePickerDialog newInstance(TimePickerDialog.OnTimeSetListener callback, boolean is24HourMode)
public void initialize(TimePickerDialog.OnTimeSetListener callback, int hourOfDay, int minute, int second, boolean is24HourMode)
public void setTitle(java.lang.String title)
public java.lang.String getTitle()
public void setThemeDark(boolean dark)
public 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 boolean isThemeDark()
public boolean is24HourMode()
public int getAccentColor()
public void vibrate(boolean vibrate)
vibrate - true if the device should vibrate when touching a fieldpublic void dismissOnPause(boolean dismissOnPause)
dismissOnPause - true if the picker should dismiss itselfpublic void enableSeconds(boolean enableSeconds)
enableSeconds - true if the seconds picker should be shownpublic void enableMinutes(boolean enableMinutes)
enableMinutes - true if minutes picker should be shownpublic void setMinTime(int hour,
int minute,
int second)
public void setMinTime(Timepoint minTime)
public void setMaxTime(int hour,
int minute,
int second)
public void setMaxTime(Timepoint maxTime)
public void setSelectableTimes(Timepoint[] selectableTimes)
selectableTimes - Array of Timepoints which are the only valid selections in the pickerpublic void setDisabledTimes(Timepoint[] disabledTimes)
setSelectableTimes(Timepoint[])
Be careful when using this without selectableTimes: rounding to a valid Timepoint is a
very expensive operation if a lot of consecutive Timepoints are disabled
Try to specify Timepoints only up to the resolution of your picker (i.e. do not add seconds
if the resolution of the picker is minutes)disabledTimes - Array of Timepoints which are disabled in the resulting pickerpublic void setTimeInterval(int hourInterval,
int minuteInterval,
int secondInterval)
setSelectableTimes(Timepoint[])
The interval for all three time components can be set independently
If you are not using the seconds / minutes picker, set the respective item to 60 for
better performance.hourInterval - The interval between 2 selectable hours ([1,24])minuteInterval - The interval between 2 selectable minutes ([1,60])secondInterval - The interval between 2 selectable seconds ([1,60])public void setTimeInterval(int hourInterval,
int minuteInterval)
hourInterval - The interval between 2 selectable hours ([1,24])minuteInterval - The interval between 2 selectable minutes ([1,60])public void setTimeInterval(int hourInterval)
hourInterval - The interval between 2 selectable hours ([1,24])public void setOnTimeSetListener(TimePickerDialog.OnTimeSetListener callback)
public void setOnCancelListener(android.content.DialogInterface.OnCancelListener onCancelListener)
public void setOnDismissListener(android.content.DialogInterface.OnDismissListener onDismissListener)
@Deprecated
public void setStartTime(int hourOfDay,
int minute,
int second)
setInitialSelection(int, int, int)hourOfDay - the hour of the dayminute - the minute of the hoursecond - the second of the minute@Deprecated
public void setStartTime(int hourOfDay,
int minute)
setInitialSelection(int, int)hourOfDay - the hour of the dayminute - the minute of the hourpublic void setInitialSelection(int hourOfDay,
int minute,
int second)
hourOfDay - the hour of the dayminute - the minute of the hoursecond - the second of the minutepublic void setInitialSelection(int hourOfDay,
int minute)
hourOfDay - the hour of the dayminute - the minute of the hourpublic void setInitialSelection(Timepoint time)
time - the Timepoint selected when the Dialog openspublic 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(TimePickerDialog.Version version)
version - The version to usepublic void setTimepointLimiter(TimepointLimiter limiter)
limiter - A custom implementation of TimeLimiterpublic TimePickerDialog.Version getVersion()
public TimePickerDialog.OnTimeSetListener getOnTimeSetListener()
public void setLocale(java.util.Locale locale)
locale - Localepublic void onCreate(android.os.Bundle savedInstanceState)
onCreate in class android.app.DialogFragmentpublic android.view.View onCreateView(android.view.LayoutInflater inflater,
android.view.ViewGroup container,
android.os.Bundle savedInstanceState)
onCreateView in class android.app.Fragmentpublic void onConfigurationChanged(android.content.res.Configuration newConfig)
onConfigurationChanged in interface android.content.ComponentCallbacksonConfigurationChanged in class android.app.Fragmentpublic android.app.Dialog onCreateDialog(android.os.Bundle savedInstanceState)
onCreateDialog in class android.app.DialogFragmentpublic void onResume()
onResume in class android.app.Fragmentpublic void onPause()
onPause in class android.app.Fragmentpublic void onCancel(android.content.DialogInterface dialog)
onCancel in interface android.content.DialogInterface.OnCancelListeneronCancel in class android.app.DialogFragmentpublic void onDismiss(android.content.DialogInterface dialog)
onDismiss in interface android.content.DialogInterface.OnDismissListeneronDismiss in class android.app.DialogFragmentpublic void tryVibrate()
public void onSaveInstanceState(android.os.Bundle outState)
onSaveInstanceState in class android.app.DialogFragmentpublic void onValueSelected(Timepoint newValue)
onValueSelected in interface RadialPickerLayout.OnValueSelectedListenerpublic void advancePicker(int index)
advancePicker in interface RadialPickerLayout.OnValueSelectedListenerpublic void enablePicker()
enablePicker in interface RadialPickerLayout.OnValueSelectedListenerpublic boolean isOutOfRange(Timepoint current)
public boolean isOutOfRange(Timepoint current, int index)
current - Timepoint - the selected point in timeindex - int - The current view to consider when calculating the rangepublic boolean isAmDisabled()
public boolean isPmDisabled()
public Timepoint roundToNearest(Timepoint time, Timepoint.TYPE type)
time - Timepoint - the timepoint to validatetype - Timepoint.TYPE - whether we should round the hours, minutes or secondspublic void notifyOnDateListener()
public Timepoint getSelectedTime()