MaterialDatePicker

public class MaterialDatePicker<S>


A Dialog with a header, MaterialCalendar, and set of actions.

For more information, see the component developer guidance and design guidelines.

Summary

Nested types

public final class MaterialDatePicker.Builder<S>

Used to create MaterialDatePicker instances with default and overridden settings

Constants

static final int

Date picker will start with calendar view.

static final int

Date picker will start with input text view.

Public fields

int

Public constructors

Public methods

boolean
addOnCancelListener(OnCancelListener onCancelListener)

The supplied listener is called when the user cancels the picker via back button or a touch outside the view.

boolean
addOnDismissListener(OnDismissListener onDismissListener)

The supplied listener is called whenever the DialogFragment is dismissed, no matter how it is dismissed.

boolean
addOnNegativeButtonClickListener(
    OnClickListener onNegativeButtonClickListener
)

The supplied listener is called when the user clicks the cancel button.

boolean

The supplied listener is called when the user confirms a valid selection.

void

Removes all listeners added via addOnCancelListener.

void

Removes all listeners added via addOnDismissListener.

void

Removes all listeners added via addOnNegativeButtonClickListener.

void

Removes all listeners added via addOnPositiveButtonClickListener.

String

Returns the text to display at the top of the DialogFragment

int

Returns the current InputMode.

final S

Returns an S instance representing the selection or null if the user has not confirmed a selection.

final void
onCancel(DialogInterface dialogInterface)
final void
onCreate(Bundle bundle)
final Dialog
onCreateDialog(Bundle bundle)
final View
onCreateView(
    LayoutInflater layoutInflater,
    ViewGroup viewGroup,
    Bundle bundle
)
final void
onDismiss(DialogInterface dialogInterface)
void

Called when the negative button on the picker has been clicked.

void

Called when the positive button on the picker has been clicked.

final void
onSaveInstanceState(Bundle bundle)
void
void
boolean
removeOnCancelListener(OnCancelListener onCancelListener)

Removes a listener previously added via addOnCancelListener.

boolean
removeOnDismissListener(OnDismissListener onDismissListener)

Removes a listener previously added via addOnDismissListener.

boolean
removeOnNegativeButtonClickListener(
    OnClickListener onNegativeButtonClickListener
)

Removes a listener previously added via addOnNegativeButtonClickListener.

boolean

Removes a listener previously added via addOnPositiveButtonClickListener.

static long

Returns the UTC milliseconds representing the first moment in current month in local timezone.

static long

Returns the UTC milliseconds representing the first moment of today in local timezone.

Constants

INPUT_MODE_CALENDAR

public static final int INPUT_MODE_CALENDAR = 0

Date picker will start with calendar view.

INPUT_MODE_TEXT

public static final int INPUT_MODE_TEXT = 1

Date picker will start with input text view.

Public fields

inputMode

public int inputMode

Public constructors

MaterialDatePicker

public MaterialDatePicker()

Public methods

addOnCancelListener

public boolean addOnCancelListener(OnCancelListener onCancelListener)

The supplied listener is called when the user cancels the picker via back button or a touch outside the view. It is not called when the user clicks the cancel button. To add a listener for use when the user clicks the cancel button, use addOnNegativeButtonClickListener.

addOnDismissListener

public boolean addOnDismissListener(OnDismissListener onDismissListener)

The supplied listener is called whenever the DialogFragment is dismissed, no matter how it is dismissed.

addOnNegativeButtonClickListener

public boolean addOnNegativeButtonClickListener(
    OnClickListener onNegativeButtonClickListener
)

The supplied listener is called when the user clicks the cancel button.

addOnPositiveButtonClickListener

public boolean addOnPositiveButtonClickListener(
    MaterialPickerOnPositiveButtonClickListener<Object> onPositiveButtonClickListener
)

The supplied listener is called when the user confirms a valid selection.

clearOnCancelListeners

public void clearOnCancelListeners()

Removes all listeners added via addOnCancelListener.

clearOnDismissListeners

public void clearOnDismissListeners()

Removes all listeners added via addOnDismissListener.

clearOnNegativeButtonClickListeners

public void clearOnNegativeButtonClickListeners()

Removes all listeners added via addOnNegativeButtonClickListener.

clearOnPositiveButtonClickListeners

public void clearOnPositiveButtonClickListeners()

Removes all listeners added via addOnPositiveButtonClickListener.

getHeaderText

public String getHeaderText()

Returns the text to display at the top of the DialogFragment

The text is updated when the Dialog launches and on user clicks.

getInputMode

public int getInputMode()

Returns the current InputMode.

getSelection

public final S getSelection()

Returns an S instance representing the selection or null if the user has not confirmed a selection.

onCancel

public final void onCancel(DialogInterface dialogInterface)

onCreate

public final void onCreate(Bundle bundle)

onCreateDialog

public final Dialog onCreateDialog(Bundle bundle)

onCreateView

public final View onCreateView(
    LayoutInflater layoutInflater,
    ViewGroup viewGroup,
    Bundle bundle
)

onDismiss

public final void onDismiss(DialogInterface dialogInterface)

onNegativeButtonClick

public void onNegativeButtonClick(View view)

Called when the negative button on the picker has been clicked.

Parameters
View view

The view that was clicked.

onPositiveButtonClick

public void onPositiveButtonClick(View view)

Called when the positive button on the picker has been clicked.

Parameters
View view

The view that was clicked.

onSaveInstanceState

public final void onSaveInstanceState(Bundle bundle)

onStart

public void onStart()

onStop

public void onStop()

removeOnCancelListener

public boolean removeOnCancelListener(OnCancelListener onCancelListener)

Removes a listener previously added via addOnCancelListener.

removeOnDismissListener

public boolean removeOnDismissListener(OnDismissListener onDismissListener)

Removes a listener previously added via addOnDismissListener.

removeOnNegativeButtonClickListener

public boolean removeOnNegativeButtonClickListener(
    OnClickListener onNegativeButtonClickListener
)

Removes a listener previously added via addOnNegativeButtonClickListener.

removeOnPositiveButtonClickListener

public boolean removeOnPositiveButtonClickListener(
    MaterialPickerOnPositiveButtonClickListener<Object> onPositiveButtonClickListener
)

Removes a listener previously added via addOnPositiveButtonClickListener.

thisMonthInUtcMilliseconds

public static long thisMonthInUtcMilliseconds()

Returns the UTC milliseconds representing the first moment in current month in local timezone.

todayInUtcMilliseconds

public static long todayInUtcMilliseconds()

Returns the UTC milliseconds representing the first moment of today in local timezone.