MaterialDatePicker.Builder

public static final class MaterialDatePicker.Builder
extends Object

java.lang.Object
   ↳ com.google.android.material.datepicker.MaterialDatePicker.Builder<S>


Used to create MaterialDatePicker instances with default and overridden settings

Summary

Public methods

MaterialDatePicker<S> build()

Creates a MaterialDatePicker with the provided options.

static Builder<Long> datePicker()

Used to create a Builder that allows for choosing a single date in the MaterialDatePicker.

static Builder<Pair<Long, Long>> dateRangePicker()

Used to create a Builder that allows for choosing a date range in the MaterialDatePicker.

Builder<S> setCalendarConstraints(CalendarConstraints bounds)

Sets the first, last, and starting month.

Builder<S> setDayViewDecorator(DayViewDecorator dayViewDecorator)

Sets the DayViewDecorator.

Builder<S> setInputMode(int inputMode)

Sets the input mode to start with.

Builder<S> setNegativeButtonContentDescription(int contentDescriptionId)

Sets the content description used in the negative button

Builder<S> setNegativeButtonContentDescription(CharSequence contentDescription)

Sets the content description used in the negative button

Builder<S> setNegativeButtonText(CharSequence text)

Sets the text used in the negative button

Builder<S> setNegativeButtonText(int textId)

Sets the text used in the negative button

Builder<S> setPositiveButtonContentDescription(CharSequence contentDescription)

Sets the content description used in the positive button

Builder<S> setPositiveButtonContentDescription(int contentDescriptionId)

Sets the content description used in the positive button

Builder<S> setPositiveButtonText(int textId)

Sets the text used in the positive button

Builder<S> setPositiveButtonText(CharSequence text)

Sets the text used in the positive button

Builder<S> setSelection(S selection)
Builder<S> setTextInputFormat(SimpleDateFormat format)

Sets the formatter that will be used to input dates using a keyboard.

Builder<S> setTheme(int themeResId)

Sets the theme controlling fullscreen mode as well as other styles.

Builder<S> setTitleText(int titleTextResId)

Sets the text used to guide the user at the top of the picker.

Builder<S> setTitleText(CharSequence charSequence)

Sets the text used to guide the user at the top of the picker.

Inherited methods

Public methods

build

public MaterialDatePicker<S> build ()

Creates a MaterialDatePicker with the provided options.

Returns
MaterialDatePicker<S>

datePicker

public static Builder<Long> datePicker ()

Used to create a Builder that allows for choosing a single date in the MaterialDatePicker.

Returns
Builder<Long>

dateRangePicker

public static Builder<Pair<Long, Long>> dateRangePicker ()

Used to create a Builder that allows for choosing a date range in the MaterialDatePicker.

Returns
Builder<Pair<Long, Long>>

setCalendarConstraints

public Builder<S> setCalendarConstraints (CalendarConstraints bounds)

Sets the first, last, and starting month.

Parameters
bounds CalendarConstraints

Returns
Builder<S>

setDayViewDecorator

public Builder<S> setDayViewDecorator (DayViewDecorator dayViewDecorator)

Sets the DayViewDecorator.

Parameters
dayViewDecorator DayViewDecorator

Returns
Builder<S>

setInputMode

public Builder<S> setInputMode (int inputMode)

Sets the input mode to start with.

Parameters
inputMode int

Returns
Builder<S>

setNegativeButtonContentDescription

public Builder<S> setNegativeButtonContentDescription (int contentDescriptionId)

Sets the content description used in the negative button

Parameters
contentDescriptionId int: resource id to be used as content description in the negative button

Returns
Builder<S>

setNegativeButtonContentDescription

public Builder<S> setNegativeButtonContentDescription (CharSequence contentDescription)

Sets the content description used in the negative button

Parameters
contentDescription CharSequence: content description used in the negative button

Returns
Builder<S>

setNegativeButtonText

public Builder<S> setNegativeButtonText (CharSequence text)

Sets the text used in the negative button

Parameters
text CharSequence: text used in the negative button

Returns
Builder<S>

setNegativeButtonText

public Builder<S> setNegativeButtonText (int textId)

Sets the text used in the negative button

Parameters
textId int: resource id to be used as text in the negative button

Returns
Builder<S>

setPositiveButtonContentDescription

public Builder<S> setPositiveButtonContentDescription (CharSequence contentDescription)

Sets the content description used in the positive button

Parameters
contentDescription CharSequence: content description used in the positive button

Returns
Builder<S>

setPositiveButtonContentDescription

public Builder<S> setPositiveButtonContentDescription (int contentDescriptionId)

Sets the content description used in the positive button

Parameters
contentDescriptionId int: resource id to be used as content description in the positive button

Returns
Builder<S>

setPositiveButtonText

public Builder<S> setPositiveButtonText (int textId)

Sets the text used in the positive button

Parameters
textId int: resource id to be used as text in the positive button

Returns
Builder<S>

setPositiveButtonText

public Builder<S> setPositiveButtonText (CharSequence text)

Sets the text used in the positive button

Parameters
text CharSequence: text used in the positive button

Returns
Builder<S>

setSelection

public Builder<S> setSelection (S selection)

Parameters
selection S

Returns
Builder<S>

setTextInputFormat

public Builder<S> setTextInputFormat (SimpleDateFormat format)

Sets the formatter that will be used to input dates using a keyboard.

This affects the hint text and error suggestions of the date input field. Using this setter requires caution to ensure dates are formatted properly in different languages and locales.

Parameters
format SimpleDateFormat: a SimpleDateFormat used to format text input dates

Returns
Builder<S>

setTheme

public Builder<S> setTheme (int themeResId)

Sets the theme controlling fullscreen mode as well as other styles.

Parameters
themeResId int

Returns
Builder<S>

setTitleText

public Builder<S> setTitleText (int titleTextResId)

Sets the text used to guide the user at the top of the picker. Defaults to a standard title based upon the type of selection.

Parameters
titleTextResId int

Returns
Builder<S>

setTitleText

public Builder<S> setTitleText (CharSequence charSequence)

Sets the text used to guide the user at the top of the picker. Setting to null will use a default title based upon the type of selection.

Parameters
charSequence CharSequence

Returns
Builder<S>