Added in API level 11

CalendarView


open class CalendarView : FrameLayout
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ android.widget.FrameLayout
   ↳ android.widget.CalendarView

This class is a calendar widget for displaying and selecting dates. The range of dates supported by this calendar is configurable.

The exact appearance and interaction model of this widget may vary between OS versions and themes (e.g. Holo versus Material), but in general a user can select a date by tapping on it and can scroll or fling the calendar to a desired date.

Summary

Nested classes
abstract

The callback used to indicate the user changes the date.

XML attributes
android:dateTextAppearance The text appearance for the day numbers in the calendar grid.
android:firstDayOfWeek The first day of week according to java.
android:focusedMonthDateColor
android:maxDate The maximal date shown by this calendar view in mm/dd/yyyy format.
android:minDate The minimal date shown by this calendar view in mm/dd/yyyy format.
android:selectedDateVerticalBar
android:selectedWeekBackgroundColor
android:showWeekNumber
android:shownWeekCount
android:unfocusedMonthDateColor
android:weekDayTextAppearance The text appearance for the week day abbreviation in the calendar header.
android:weekNumberColor
android:weekSeparatorLineColor
Inherited XML attributes
Inherited constants
Public constructors

CalendarView(context: Context, attrs: AttributeSet?)

CalendarView(context: Context, attrs: AttributeSet?, defStyleAttr: Int)

CalendarView(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int)

Public methods
open CharSequence!

open Long

Gets the selected date in milliseconds since January 1, 1970 00:00:00 in TimeZone#getDefault() time zone.

open Int

Gets the text appearance for the calendar dates.

open Int

Gets the first day of week.

open Int

Gets the color for the dates in the focused month.

open Long

Gets the maximal date supported by this CalendarView in milliseconds since January 1, 1970 00:00:00 in TimeZone#getDefault() time zone.

open Long

Gets the minimal date supported by this CalendarView in milliseconds since January 1, 1970 00:00:00 in TimeZone#getDefault() time zone.

open Drawable!

Gets the drawable for the vertical bar shown at the beginning and at the end of the selected date.

open Int

Gets the background color for the selected week.

open Boolean

Gets whether to show the week number.

open Int

Gets the number of weeks to be shown.

open Int

Gets the color for the dates in a not focused month.

open Int

Gets the text appearance for the week day abbreviation of the calendar header.

open Int

Gets the color for the week numbers.

open Int

Gets the color for the separator line between weeks.

open Unit
setDate(date: Long)

Sets the selected date in milliseconds since January 1, 1970 00:00:00 in TimeZone#getDefault() time zone.

open Unit
setDate(date: Long, animate: Boolean, center: Boolean)

Sets the selected date in milliseconds since January 1, 1970 00:00:00 in TimeZone#getDefault() time zone.

open Unit

Sets the text appearance for the calendar dates.

open Unit
setFirstDayOfWeek(firstDayOfWeek: Int)

Sets the first day of week.

open Unit

Sets the color for the dates of the focused month.

open Unit
setMaxDate(maxDate: Long)

Sets the maximal date supported by this CalendarView in milliseconds since January 1, 1970 00:00:00 in TimeZone#getDefault() time zone.

open Unit
setMinDate(minDate: Long)

Sets the minimal date supported by this CalendarView in milliseconds since January 1, 1970 00:00:00 in TimeZone#getDefault() time zone.

open Unit

Sets the listener to be notified upon selected date change.

open Unit

Sets the drawable for the vertical bar shown at the beginning and at the end of the selected date.

open Unit

Sets the drawable for the vertical bar shown at the beginning and at the end of the selected date.

open Unit

Sets the background color for the selected week.

open Unit
setShowWeekNumber(showWeekNumber: Boolean)

Sets whether to show the week number.

open Unit

Sets the number of weeks to be shown.

open Unit

Sets the color for the dates of a not focused month.

open Unit

Sets the text appearance for the week day abbreviation of the calendar header.

open Unit

Sets the color for the week numbers.

open Unit

Sets the color for the separator line between weeks.

Protected methods
open Unit

Inherited functions
Inherited properties

XML attributes

android:dateTextAppearance

android:dateTextAppearance
The text appearance for the day numbers in the calendar grid.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

android:firstDayOfWeek

android:firstDayOfWeek
The first day of week according to java.util.Calendar.

May be an integer value, such as "100".

android:focusedMonthDateColor

android:focusedMonthDateColor

android:maxDate

android:maxDate
The maximal date shown by this calendar view in mm/dd/yyyy format.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

android:minDate

android:minDate
The minimal date shown by this calendar view in mm/dd/yyyy format.

May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character;

android:selectedDateVerticalBar

android:selectedDateVerticalBar

android:selectedWeekBackgroundColor

android:selectedWeekBackgroundColor

android:showWeekNumber

android:showWeekNumber

android:shownWeekCount

android:shownWeekCount

android:unfocusedMonthDateColor

android:unfocusedMonthDateColor

android:weekDayTextAppearance

android:weekDayTextAppearance
The text appearance for the week day abbreviation in the calendar header.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

android:weekNumberColor

android:weekNumberColor

android:weekSeparatorLineColor

android:weekSeparatorLineColor

Public constructors

CalendarView

Added in API level 11
CalendarView(context: Context)
Parameters
context Context: This value cannot be null.

CalendarView

Added in API level 11
CalendarView(
    context: Context,
    attrs: AttributeSet?)
Parameters
context Context: This value cannot be null.
attrs AttributeSet?: This value may be null.

CalendarView

Added in API level 11
CalendarView(
    context: Context,
    attrs: AttributeSet?,
    defStyleAttr: Int)
Parameters
context Context: This value cannot be null.
attrs AttributeSet?: This value may be null.

CalendarView

Added in API level 21
CalendarView(
    context: Context,
    attrs: AttributeSet?,
    defStyleAttr: Int,
    defStyleRes: Int)
Parameters
context Context: This value cannot be null.
attrs AttributeSet?: This value may be null.

Public methods

getAccessibilityClassName

Added in API level 23
open fun getAccessibilityClassName(): CharSequence!

getDate

Added in API level 11
open fun getDate(): Long

Gets the selected date in milliseconds since January 1, 1970 00:00:00 in TimeZone#getDefault() time zone.

Return
Long The selected date.

getDateTextAppearance

Added in API level 16
open fun getDateTextAppearance(): Int

Gets the text appearance for the calendar dates.

Return
Int The text appearance resource id.

getFocusedMonthDateColor

Added in API level 16
Deprecated in API level 23
open fun getFocusedMonthDateColor(): Int

Deprecated: No longer used by Material-style CalendarView.

Gets the color for the dates in the focused month.

Return
Int The focused month date color.

getMaxDate

Added in API level 11
open fun getMaxDate(): Long

Gets the maximal date supported by this CalendarView in milliseconds since January 1, 1970 00:00:00 in TimeZone#getDefault() time zone.

Note: The default maximal date is 01/01/2100.

Return
Long The maximal supported date.

getMinDate

Added in API level 11
open fun getMinDate(): Long

Gets the minimal date supported by this CalendarView in milliseconds since January 1, 1970 00:00:00 in TimeZone#getDefault() time zone.

Note: The default minimal date is 01/01/1900.

Return
Long The minimal supported date.

getSelectedDateVerticalBar

Added in API level 16
Deprecated in API level 23
open fun getSelectedDateVerticalBar(): Drawable!

Deprecated: No longer used by Material-style CalendarView.

Gets the drawable for the vertical bar shown at the beginning and at the end of the selected date.

Return
Drawable! The vertical bar drawable.

getSelectedWeekBackgroundColor

Added in API level 16
Deprecated in API level 23
open fun getSelectedWeekBackgroundColor(): Int

Deprecated: No longer used by Material-style CalendarView.

Gets the background color for the selected week.

Return
Int The week background color.

getShowWeekNumber

Added in API level 11
Deprecated in API level 24
open fun getShowWeekNumber(): Boolean

Deprecated: No longer used by Material-style CalendarView.

Gets whether to show the week number.

Return
Boolean True if showing the week number.

getShownWeekCount

Added in API level 16
Deprecated in API level 23
open fun getShownWeekCount(): Int

Deprecated: No longer used by Material-style CalendarView.

Gets the number of weeks to be shown.

Return
Int The shown week count.

getUnfocusedMonthDateColor

Added in API level 16
Deprecated in API level 23
open fun getUnfocusedMonthDateColor(): Int

Deprecated: No longer used by Material-style CalendarView.

Gets the color for the dates in a not focused month.

Return
Int A not focused month date color.

getWeekDayTextAppearance

Added in API level 16
open fun getWeekDayTextAppearance(): Int

Gets the text appearance for the week day abbreviation of the calendar header.

Return
Int The text appearance resource id.

getWeekNumberColor

Added in API level 16
Deprecated in API level 23
open fun getWeekNumberColor(): Int

Deprecated: No longer used by Material-style CalendarView.

Gets the color for the week numbers.

Return
Int The week number color.

getWeekSeparatorLineColor

Added in API level 16
Deprecated in API level 23
open fun getWeekSeparatorLineColor(): Int

Deprecated: No longer used by Material-style CalendarView.

Gets the color for the separator line between weeks.

Return
Int The week separator color.

setDate

Added in API level 11
open fun setDate(date: Long): Unit

Sets the selected date in milliseconds since January 1, 1970 00:00:00 in TimeZone#getDefault() time zone.

Parameters
date Long: The selected date.
Exceptions
java.lang.IllegalArgumentException of the provided date is before the minimal or after the maximal date.

setDate

Added in API level 11
open fun setDate(
    date: Long,
    animate: Boolean,
    center: Boolean
): Unit

Sets the selected date in milliseconds since January 1, 1970 00:00:00 in TimeZone#getDefault() time zone.

Parameters
date Long: The date.
animate Boolean: Whether to animate the scroll to the current date.
center Boolean: Whether to center the current date even if it is already visible.
Exceptions
java.lang.IllegalArgumentException of the provided date is before the minimal or after the maximal date.

setDateTextAppearance

Added in API level 16
open fun setDateTextAppearance(resourceId: Int): Unit

Sets the text appearance for the calendar dates.

Parameters
resourceId Int: The text appearance resource id.

setFirstDayOfWeek

Added in API level 11
open fun setFirstDayOfWeek(firstDayOfWeek: Int): Unit

Sets the first day of week.

Parameters
firstDayOfWeek Int: The first day of the week conforming to the CalendarView APIs.

setFocusedMonthDateColor

Added in API level 16
Deprecated in API level 23
open fun setFocusedMonthDateColor(color: Int): Unit

Deprecated: No longer used by Material-style CalendarView.

Sets the color for the dates of the focused month.

Parameters
color Int: The focused month date color.

setMaxDate

Added in API level 11
open fun setMaxDate(maxDate: Long): Unit

Sets the maximal date supported by this CalendarView in milliseconds since January 1, 1970 00:00:00 in TimeZone#getDefault() time zone.

Parameters
maxDate Long: The maximal supported date.

setMinDate

Added in API level 11
open fun setMinDate(minDate: Long): Unit

Sets the minimal date supported by this CalendarView in milliseconds since January 1, 1970 00:00:00 in TimeZone#getDefault() time zone.

Parameters
minDate Long: The minimal supported date.

setOnDateChangeListener

Added in API level 11
open fun setOnDateChangeListener(listener: CalendarView.OnDateChangeListener!): Unit

Sets the listener to be notified upon selected date change.

Parameters
listener CalendarView.OnDateChangeListener!: The listener to be notified.

setSelectedDateVerticalBar

Added in API level 16
Deprecated in API level 23
open fun setSelectedDateVerticalBar(resourceId: Int): Unit

Deprecated: No longer used by Material-style CalendarView.

Sets the drawable for the vertical bar shown at the beginning and at the end of the selected date.

Parameters
resourceId Int: The vertical bar drawable resource id.

setSelectedDateVerticalBar

Added in API level 16
Deprecated in API level 23
open fun setSelectedDateVerticalBar(drawable: Drawable!): Unit

Deprecated: No longer used by Material-style CalendarView.

Sets the drawable for the vertical bar shown at the beginning and at the end of the selected date.

Parameters
drawable Drawable!: The vertical bar drawable.

setSelectedWeekBackgroundColor

Added in API level 16
Deprecated in API level 23
open fun setSelectedWeekBackgroundColor(color: Int): Unit

Deprecated: No longer used by Material-style CalendarView.

Sets the background color for the selected week.

Parameters
color Int: The week background color.

setShowWeekNumber

Added in API level 11
Deprecated in API level 24
open fun setShowWeekNumber(showWeekNumber: Boolean): Unit

Deprecated: No longer used by Material-style CalendarView.

Sets whether to show the week number.

Parameters
showWeekNumber Boolean: True to show the week number.

setShownWeekCount

Added in API level 16
Deprecated in API level 23
open fun setShownWeekCount(count: Int): Unit

Deprecated: No longer used by Material-style CalendarView.

Sets the number of weeks to be shown.

Parameters
count Int: The shown week count.

setUnfocusedMonthDateColor

Added in API level 16
Deprecated in API level 23
open fun setUnfocusedMonthDateColor(color: Int): Unit

Deprecated: No longer used by Material-style CalendarView.

Sets the color for the dates of a not focused month.

Parameters
color Int: A not focused month date color.

setWeekDayTextAppearance

Added in API level 16
open fun setWeekDayTextAppearance(resourceId: Int): Unit

Sets the text appearance for the week day abbreviation of the calendar header.

Parameters
resourceId Int: The text appearance resource id.

setWeekNumberColor

Added in API level 16
Deprecated in API level 23
open fun setWeekNumberColor(color: Int): Unit

Deprecated: No longer used by Material-style CalendarView.

Sets the color for the week numbers.

Parameters
color Int: The week number color.

setWeekSeparatorLineColor

Added in API level 16
Deprecated in API level 23
open fun setWeekSeparatorLineColor(color: Int): Unit

Deprecated: No longer used by Material-style CalendarView.

Sets the color for the separator line between weeks.

Parameters
color Int: The week separator color.

Protected methods

onConfigurationChanged

Added in API level 11
protected open fun onConfigurationChanged(newConfig: Configuration!): Unit
Parameters
newConfig Configuration!: The new resource configuration.