10

I need to highlight several dates in a CalendaView. that should look like, enter image description here

I tried setDate(), but it didn't work as I want. Please help me to find a solution. Thanks in advance.

Kavin-K
  • 1,948
  • 3
  • 17
  • 48
  • Possible duplicate of [Android CalendarView for Showing Events](https://stackoverflow.com/questions/16556254/android-calendarview-for-showing-events) – The Dreams Wind Nov 23 '17 at 08:32

1 Answers1

12

Follow this link to get the library mCalendarView

  1. Use 3rd party library McalenderView.

  2. Add to your gradle:

    sun.bob:mcalendarview:1.0.0

Try this code:

  1. Some code:
calendarView = ((MCalendarView) view.findViewById(R.id.calendar_exp));

ArrayList<DateData> dates=new ArrayList<>();
dates.add(new DateData(2018,04,26));
dates.add(new DateData(2018,04,27));

for(int i=0;i<dates.size();i++) {
    //mark multiple dates with this code.
    calendarView.markDate(dates.get(i).getYear(),dates.get(i).getMonth(),dates.get(i).getDay()); 
}


Log.d("marked dates:-","" + calendarView.getMarkedDates()); //get all marked dates.
Bruno Bieri
  • 9,724
  • 11
  • 63
  • 92
sagar potdar
  • 598
  • 1
  • 6
  • 22