How to highlight multiple dates in a android CalendarView programmatically

纵饮孤独 提交于 2019-12-09 13:15:53

问题


I need to highlight several dates in a CalendaView. that should look like,

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


回答1:


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:-

3.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++) {
        calendarView.markDate(dates.get(i).getYear(),dates.get(i).getMonth(),dates.get(i).getDay());//mark multiple dates with this code.
    }


    Log.d("marked dates:-",""+calendarView.getMarkedDates());//get all marked dates.


来源:https://stackoverflow.com/questions/47450529/how-to-highlight-multiple-dates-in-a-android-calendarview-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!