【问题标题】:How to highlight multiple dates in a android CalendarView programmatically如何以编程方式突出显示 android CalendarView 中的多个日期
【发布时间】:2021-07-02 15:07:59
【问题描述】:

我需要在 CalendaView 中突出显示几个日期。应该是这样的,

我尝试了setDate(),但它没有按我的意愿工作。请帮我找到解决方案。提前致谢。

【问题讨论】:

标签: android calendarview


【解决方案1】:

Follow this link to get the library mCalendarView

  1. 使用第 3 方库 McalenderView。

  2. 添加到你的 gradle:

    sun.bob:mcalendarview:1.0.0

试试这个代码:

  1. 一些代码:
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.

【讨论】:

  • 这解决了您的问题吗?请接受这个答案。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多