本文介绍了如何以编程方式突出显示Android CalendarView中的多个日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在CalendaView中突出显示几个日期.看起来应该像

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

我尝试了 setDate(),但是它并没有按照我的要求工作.请帮助我找到解决方案.预先感谢.

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

推荐答案

点击此链接以获取库mCalendarView

1.使用第三方库McalenderView.

1.Use 3rd party library McalenderView.

2.添加到您的gradle:-

2.Add to your gradle:-

'sun.bob:mcalendarview:1.0.0'

尝试此代码:-

3.一些代码:-

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.

这篇关于如何以编程方式突出显示Android CalendarView中的多个日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-03 10:53