I was searching for a way to add marker on particular dates, but didn't find any.
However as you can see in above image, I have managed to add marker to Calendar dates.
I have used addConnectedDays() provided by Cosmo Calendar.
Markers can be added on TOP & BOTTOM of date.
Sharing code I used:
Set<Long> days = new TreeSet<>();
e.g.
String date1 = "05-18-2021";
String date2 = "05-09-2021";
//........
SimpleDateFormat sdf1 = new SimpleDateFormat("MM-dd-yyyy");
try {
Date mDate1 = sdf1.parse(date1);
long timeInMilliseconds1 = mDate1.getTime();
Date mDate2 = sdf1.parse(date2);
long timeInMilliseconds2 = mDate2.getTime();
days.add(timeInMilliseconds1);
days.add(timeInMilliseconds2);
// can add more days to set
} catch (Exception e) {
Log.e("DateException", e.getMessage());
}
int textColor = Color.parseColor("#0063B0");
int selectedTextColor = Color.parseColor("#FFFFFF");
int disabledTextColor = Color.parseColor("#ff8000");
ConnectedDays connectedDays = new ConnectedDays(days, textColor, selectedTextColor, disabledTextColor);
//Add Connect days to calendar
calendarView.addConnectedDays(connectedDays);
calendarView.setConnectedDayIconRes(R.drawable.ic_baseline_star_24); // Drawable
calendarView.setConnectedDayIconPosition(ConnectedDayIconPosition.TOP);// TOP & BOTTOM
calendarView.update();
### SOLUTION TO ADD EVENTS
I was searching for a way to add marker on particular dates, but didn't find any. However as you can see in above image, I have managed to add marker to Calendar dates. I have used addConnectedDays() provided by Cosmo Calendar. Markers can be added on TOP & BOTTOM of date. Sharing code I used: