FileDocCategorySizeDatePackage
CalendarView.javaAPI DocAndroid 5.1 API19655Thu Mar 12 22:22:10 GMT 2015android.widget

CalendarView

public class CalendarView extends FrameLayout
This class is a calendar widget for displaying and selecting dates. The range of dates supported by this calendar is configurable. A user can select a date by taping on it and can scroll and fling the calendar to a desired date.
attr
ref android.R.styleable#CalendarView_showWeekNumber
attr
ref android.R.styleable#CalendarView_firstDayOfWeek
attr
ref android.R.styleable#CalendarView_minDate
attr
ref android.R.styleable#CalendarView_maxDate
attr
ref android.R.styleable#CalendarView_shownWeekCount
attr
ref android.R.styleable#CalendarView_selectedWeekBackgroundColor
attr
ref android.R.styleable#CalendarView_focusedMonthDateColor
attr
ref android.R.styleable#CalendarView_unfocusedMonthDateColor
attr
ref android.R.styleable#CalendarView_weekNumberColor
attr
ref android.R.styleable#CalendarView_weekSeparatorLineColor
attr
ref android.R.styleable#CalendarView_selectedDateVerticalBar
attr
ref android.R.styleable#CalendarView_weekDayTextAppearance
attr
ref android.R.styleable#CalendarView_dateTextAppearance

Fields Summary
private static final String
LOG_TAG
private static final int
MODE_HOLO
private static final int
MODE_MATERIAL
private final CalendarViewDelegate
mDelegate
Constructors Summary
public CalendarView(android.content.Context context)


                   
       

                                                         
                 
    

       
        this(context, null);
    
public CalendarView(android.content.Context context, android.util.AttributeSet attrs)

        this(context, attrs, R.attr.calendarViewStyle);
    
public CalendarView(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr)

        this(context, attrs, defStyleAttr, 0);
    
public CalendarView(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr, int defStyleRes)

        super(context, attrs, defStyleAttr, defStyleRes);

        final TypedArray a = context.obtainStyledAttributes(
                attrs, R.styleable.CalendarView, defStyleAttr, defStyleRes);
        final int mode = a.getInt(R.styleable.CalendarView_calendarViewMode, MODE_HOLO);
        a.recycle();

        switch (mode) {
            case MODE_HOLO:
                mDelegate = new CalendarViewLegacyDelegate(
                        this, context, attrs, defStyleAttr, defStyleRes);
                break;
            case MODE_MATERIAL:
                mDelegate = new CalendarViewMaterialDelegate(
                        this, context, attrs, defStyleAttr, defStyleRes);
                break;
            default:
                throw new IllegalArgumentException("invalid calendarViewMode attribute");
        }
    
Methods Summary
public longgetDate()
Gets the selected date in milliseconds since January 1, 1970 00:00:00 in {@link TimeZone#getDefault()} time zone.

return
The selected date.

        return mDelegate.getDate();
    
public intgetDateTextAppearance()
Gets the text appearance for the calendar dates.

return
The text appearance resource id.
attr
ref android.R.styleable#CalendarView_dateTextAppearance

        return mDelegate.getDateTextAppearance();
    
public intgetFirstDayOfWeek()
Gets the first day of week.

return
The first day of the week conforming to the {@link CalendarView} APIs.
see
Calendar#MONDAY
see
Calendar#TUESDAY
see
Calendar#WEDNESDAY
see
Calendar#THURSDAY
see
Calendar#FRIDAY
see
Calendar#SATURDAY
see
Calendar#SUNDAY
attr
ref android.R.styleable#CalendarView_firstDayOfWeek

        return mDelegate.getFirstDayOfWeek();
    
public intgetFocusedMonthDateColor()
Gets the color for the dates in the focused month.

return
The focused month date color.
attr
ref android.R.styleable#CalendarView_focusedMonthDateColor

        return mDelegate.getFocusedMonthDateColor();
    
public longgetMaxDate()
Gets the maximal date supported by this {@link CalendarView} in milliseconds since January 1, 1970 00:00:00 in {@link TimeZone#getDefault()} time zone.

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

return
The maximal supported date.
attr
ref android.R.styleable#CalendarView_maxDate

        return mDelegate.getMaxDate();
    
public longgetMinDate()
Gets the minimal date supported by this {@link CalendarView} in milliseconds since January 1, 1970 00:00:00 in {@link TimeZone#getDefault()} time zone.

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

return
The minimal supported date.
attr
ref android.R.styleable#CalendarView_minDate

        return mDelegate.getMinDate();
    
public android.graphics.drawable.DrawablegetSelectedDateVerticalBar()
Gets the drawable for the vertical bar shown at the beginning and at the end of the selected date.

return
The vertical bar drawable.

        return mDelegate.getSelectedDateVerticalBar();
    
public intgetSelectedWeekBackgroundColor()
Gets the background color for the selected week.

return
The week background color.
attr
ref android.R.styleable#CalendarView_selectedWeekBackgroundColor

        return mDelegate.getSelectedWeekBackgroundColor();
    
public booleangetShowWeekNumber()
Gets whether to show the week number.

return
True if showing the week number.
attr
ref android.R.styleable#CalendarView_showWeekNumber

        return mDelegate.getShowWeekNumber();
    
public intgetShownWeekCount()
Gets the number of weeks to be shown.

return
The shown week count.
attr
ref android.R.styleable#CalendarView_shownWeekCount

        return mDelegate.getShownWeekCount();
    
public intgetUnfocusedMonthDateColor()
Gets the color for the dates in a not focused month.

return
A not focused month date color.
attr
ref android.R.styleable#CalendarView_unfocusedMonthDateColor

        return mDelegate.getUnfocusedMonthDateColor();
    
public intgetWeekDayTextAppearance()
Gets the text appearance for the week day abbreviation of the calendar header.

return
The text appearance resource id.
attr
ref android.R.styleable#CalendarView_weekDayTextAppearance

        return mDelegate.getWeekDayTextAppearance();
    
public intgetWeekNumberColor()
Gets the color for the week numbers.

return
The week number color.
attr
ref android.R.styleable#CalendarView_weekNumberColor

        return mDelegate.getWeekNumberColor();
    
public intgetWeekSeparatorLineColor()
Gets the color for the separator line between weeks.

return
The week separator color.
attr
ref android.R.styleable#CalendarView_weekSeparatorLineColor

        return mDelegate.getWeekSeparatorLineColor();
    
protected voidonConfigurationChanged(android.content.res.Configuration newConfig)

        super.onConfigurationChanged(newConfig);
        mDelegate.onConfigurationChanged(newConfig);
    
public voidonInitializeAccessibilityEvent(android.view.accessibility.AccessibilityEvent event)

        event.setClassName(CalendarView.class.getName());
    
public voidonInitializeAccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo info)

        info.setClassName(CalendarView.class.getName());
    
public voidsetDate(long date)
Sets the selected date in milliseconds since January 1, 1970 00:00:00 in {@link TimeZone#getDefault()} time zone.

param
date The selected date.
throws
IllegalArgumentException of the provided date is before the minimal or after the maximal date.
see
#setDate(long, boolean, boolean)
see
#setMinDate(long)
see
#setMaxDate(long)

        mDelegate.setDate(date);
    
public voidsetDate(long date, boolean animate, boolean center)
Sets the selected date in milliseconds since January 1, 1970 00:00:00 in {@link TimeZone#getDefault()} time zone.

param
date The date.
param
animate Whether to animate the scroll to the current date.
param
center Whether to center the current date even if it is already visible.
throws
IllegalArgumentException of the provided date is before the minimal or after the maximal date.
see
#setMinDate(long)
see
#setMaxDate(long)

        mDelegate.setDate(date, animate, center);
    
public voidsetDateTextAppearance(int resourceId)
Sets the text appearance for the calendar dates.

param
resourceId The text appearance resource id.
attr
ref android.R.styleable#CalendarView_dateTextAppearance

        mDelegate.setDateTextAppearance(resourceId);
    
public voidsetFirstDayOfWeek(int firstDayOfWeek)
Sets the first day of week.

param
firstDayOfWeek The first day of the week conforming to the {@link CalendarView} APIs.
see
Calendar#MONDAY
see
Calendar#TUESDAY
see
Calendar#WEDNESDAY
see
Calendar#THURSDAY
see
Calendar#FRIDAY
see
Calendar#SATURDAY
see
Calendar#SUNDAY
attr
ref android.R.styleable#CalendarView_firstDayOfWeek

        mDelegate.setFirstDayOfWeek(firstDayOfWeek);
    
public voidsetFocusedMonthDateColor(int color)
Sets the color for the dates of the focused month.

param
color The focused month date color.
attr
ref android.R.styleable#CalendarView_focusedMonthDateColor

        mDelegate.setFocusedMonthDateColor(color);
    
public voidsetMaxDate(long maxDate)
Sets the maximal date supported by this {@link CalendarView} in milliseconds since January 1, 1970 00:00:00 in {@link TimeZone#getDefault()} time zone.

param
maxDate The maximal supported date.
attr
ref android.R.styleable#CalendarView_maxDate

        mDelegate.setMaxDate(maxDate);
    
public voidsetMinDate(long minDate)
Sets the minimal date supported by this {@link CalendarView} in milliseconds since January 1, 1970 00:00:00 in {@link TimeZone#getDefault()} time zone.

param
minDate The minimal supported date.
attr
ref android.R.styleable#CalendarView_minDate

        mDelegate.setMinDate(minDate);
    
public voidsetOnDateChangeListener(android.widget.CalendarView$OnDateChangeListener listener)
Sets the listener to be notified upon selected date change.

param
listener The listener to be notified.

        mDelegate.setOnDateChangeListener(listener);
    
public voidsetSelectedDateVerticalBar(int resourceId)
Sets the drawable for the vertical bar shown at the beginning and at the end of the selected date.

param
resourceId The vertical bar drawable resource id.
attr
ref android.R.styleable#CalendarView_selectedDateVerticalBar

        mDelegate.setSelectedDateVerticalBar(resourceId);
    
public voidsetSelectedDateVerticalBar(android.graphics.drawable.Drawable drawable)
Sets the drawable for the vertical bar shown at the beginning and at the end of the selected date.

param
drawable The vertical bar drawable.
attr
ref android.R.styleable#CalendarView_selectedDateVerticalBar

        mDelegate.setSelectedDateVerticalBar(drawable);
    
public voidsetSelectedWeekBackgroundColor(int color)
Sets the background color for the selected week.

param
color The week background color.
attr
ref android.R.styleable#CalendarView_selectedWeekBackgroundColor

        mDelegate.setSelectedWeekBackgroundColor(color);
    
public voidsetShowWeekNumber(boolean showWeekNumber)
Sets whether to show the week number.

param
showWeekNumber True to show the week number.
attr
ref android.R.styleable#CalendarView_showWeekNumber

        mDelegate.setShowWeekNumber(showWeekNumber);
    
public voidsetShownWeekCount(int count)
Sets the number of weeks to be shown.

param
count The shown week count.
attr
ref android.R.styleable#CalendarView_shownWeekCount

        mDelegate.setShownWeekCount(count);
    
public voidsetUnfocusedMonthDateColor(int color)
Sets the color for the dates of a not focused month.

param
color A not focused month date color.
attr
ref android.R.styleable#CalendarView_unfocusedMonthDateColor

        mDelegate.setUnfocusedMonthDateColor(color);
    
public voidsetWeekDayTextAppearance(int resourceId)
Sets the text appearance for the week day abbreviation of the calendar header.

param
resourceId The text appearance resource id.
attr
ref android.R.styleable#CalendarView_weekDayTextAppearance

        mDelegate.setWeekDayTextAppearance(resourceId);
    
public voidsetWeekNumberColor(int color)
Sets the color for the week numbers.

param
color The week number color.
attr
ref android.R.styleable#CalendarView_weekNumberColor

        mDelegate.setWeekNumberColor(color);
    
public voidsetWeekSeparatorLineColor(int color)
Sets the color for the separator line between weeks.

param
color The week separator color.
attr
ref android.R.styleable#CalendarView_weekSeparatorLineColor

        mDelegate.setWeekSeparatorLineColor(color);