如何以编程方式突出显示 android CalendarView 中的多个日期
How to highlight multiple dates in a android CalendarView programmatically
我需要在 CalendaView 中突出显示几个日期。应该看起来像
我尝试了 setDate()
,但没有达到我想要的效果。请帮我找到解决办法。提前致谢。
Follow this link to get the library mCalendarView
使用第 3 方库 McalenderView。
添加到您的gradle:
sun.bob:mcalendarview:1.0.0
试试这个代码:
- 一些代码:
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.
我需要在 CalendaView 中突出显示几个日期。应该看起来像
我尝试了 setDate()
,但没有达到我想要的效果。请帮我找到解决办法。提前致谢。
Follow this link to get the library mCalendarView
使用第 3 方库 McalenderView。
添加到您的gradle:
sun.bob:mcalendarview:1.0.0
试试这个代码:
- 一些代码:
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.