-
Events can be displayed on the calendar.
simpleCalendar.setOnEventListener((startTimestamp, endTimestamp) -> { // Feb // +------ ... ------+ // | 1 | 2 | ... | 7 | // StartTimestamp is '1 Feb' at unixtime // | ... | // | ... |28 | // | 1 | ... | // | ... |14 | // EndTimestamp is '14 Mar' at unixtime // +------ ... ------+ // TODO return List events from startTimestamp to endTimeStamp // DayEvent object can set title, color of background, color of title and time. return (List<DayEvent>)list; } );
- Add a specific day as a holiday.
simpleCalendar.setOnHolidayListener((year, month) -> { // New Year Holiday (1/Jan) of Korea. if( month == 1 ) return Collections.singletonList(1L); // TODO write your holiday format (day list) return null; });
- Know the date that you clicked in the calendar.
simpleCalendar.setOnDayClickListener(time -> { Log.i(MainActivity.class.getSimpleName(), "click on : " + WeekFormat.getDateStringBestFmt(new Date(time), "yyyy MM dd")); list.add(new DayEvent("sample", time, time)); simpleCalendar.notifyDataSetChanged(); // TODO write what do you do });
-
Know what month it is whenever you swipe.
simpleCalendar.setOnSwipeMonthListener(time -> // TODO When changed the page, write for what to do Toast.makeText(MainActivity.this, "swipe on : " + WeekFormat.getDateStringBestFmt(new Date(time), "MM"), Toast.LENGTH_SHORT).show() );
-
Move a calendar to a specific date.
c.setTimeInMillis(today); c.set(Calendar.MONTH, 3); // Maple simpleCalendar.setDate(c.getTimeInMillis());
- build.gradle in preject
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
- build.gradle in app
android{
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
dependencies {
implementation 'com.github.lhjnano:SimpleCalendar:1.0.1' // Put in recently version code
}
minSdkVersion is 19, targetSdkVersion is 30 in version 1.0.1
See LICENSE details.