CustomCalendarView

View on github Releases

Manjit Borah

Add custom calendar to your android project :

1. Add this to your project-level gradle file
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

2. Add this to your app-level gradle file
dependencies {
    implementation 'com.github.manjitborah2710:mcalendarView:2.1'
}


Mark Dates

...

customCalendarView.setOnDateClickedListener(new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView parent, View view, int position, long id){
         customCalendarView.markDate(view,position);
    }
});

...

Set Maximum and Minimum Dates

...

customCalendarView.setMinDate(calendarMin);
customCalendarView.setMaxDate(calendarMax);
customCalendarView.setCalendar(customCalendarView.getCurrentDisplayableCalendar());

...

Method
Parameters
Return Value
Description
getCurrentActualCalendar() Calendar Returns the Calendar instance at the time of method call
getCurrentActualCalendar(String pattern) pattern: The pattern in the form of which the returned date is formatted String Returns a String value of the current date in the form of pattern
getCurrentDisplayableCalendar() Calendar Returns the Calendar instance which is being applied to the CalendarView at the time of method call
getCurrentDisplayableCalendar(String pattern) pattern: The pattern in the form of which the returned date is formatted String Returns a String value of the current displayed calendar in the form of pattern
getMarkedDates() List Returns the list of the dates marked
getMarkedDatesStringList() List Returns the list of the marked dates formatted as String
getDate(int pos) pos: The position in the CalendarView of which the date is to be returned Date Returns the Date at the position pos of the CalendarView
setCalendar() void Sets the CalendarView to the actual Current date calendar. Internally calls setCurrentDisplayableCalendar(Calendar calendar)
setCalendar(Calendar calendar) calendar: the calendar which is to be set to the CalendarView void Sets the CalendarView to the calendar passed as calendar. Internally calls setCurrentDisplayableCalendar(Calendar calendar)
setCurrentDisplayableCalendar(Calendar calendar) calendar: the calendar which is to be set to the currentDisplayableCalendar variable. void Sets the variable currentDisplayableCalendar to the value passed as calendar. It does not bring about any changes, it just sets the mentioned variable.
setMaxDate(Calendar calendar) calendar: the calendar object which describes the maximum date to be enabled in the CalendarView void Sets the maximum date in the CalendarView
setMinDate(Calendar calendar) calendar: the calendar object which describes the minimum date to be enabled in the CalendarView void Sets the minimum date in the CalendarView
setOnlySpecifiedMonth(Calendar calendar) calendar: the calendar object which describes the month enabled in the CalendarView void Sets the month to be displayable in the CalendarView. Disables the previous and next buttons in the CalendarView
setOnDateClickedListener(AdapterView.OnItemClickListener listener) listener: an object of a class implementing AdapterView.OnItemClickListener void Attaches a listener that overrides the method:
public void onItemClick(AdapterView parent, View view, int position, long id);
markDate(View view,int pos) view: the view passed with the callback onItemClick(…)
pos: the position passed with the callback onItemClick(…)
void Marks the clicked date on the CalendarView.
markDates(List dates) dates: a list of Date objects which are to be marked on the CalendarView void Marks the dates specified in the list dates
unmarkDate(View view,int pos) view: the view passed with the callback onItemClick(…)
pos: the position passed with the callback onItemClick(…)
void Unmarks the clicked date on the CalendarView.