一、概述

MaterialCalendarView是一个开源项目。功能强大支持多选、单选、标注等。

二、问题

1、其继承自ViewGroup,故与CalendarView半毛钱关系都没有,完全是一个新的类

2、其子类CalendarDay是经过调整的

CalendarDay date = new CalendarDay();
......
Log.e(LOG_TAG, "Date选中日期:" + date.getDate().getYear() + "-" + date.getDate().getMonth() + "-" + date.getDate().getDay());
Log.e(LOG_TAG, "Calendar选中日期:" + date.getCalendar().get(Calendar.YEAR) + "-" + (date.getCalendar().get(Calendar.MONTH) + 1) + "-" + date.getCalendar().get(Calendar.DAY_OF_MONTH));

得到的结果为

Date选中日期:116-3-6
Calendar选中日期:2016-4-30

即:

CalendarDay.getDate().getYear()得到的年份 = 真实年份 - 1900
CalendarDay.getDate().getMonth()得到的月份 = 真实年份 - 1
CalendarDay.getDate().getDay()得到的日 = 星期数 - 1

3、关于DayViewDecorator类

此类为抽象类,定义如下

/**
* Decorate Day views with drawables and text manipulation
*/
public interface DayViewDecorator { /**
* Determine if a specific day should be decorated
*
* @param day {@linkplain CalendarDay} to possibly decorate
* @return true if this decorator should be applied to the provided day
*/
boolean shouldDecorate(CalendarDay day); /**
* Set decoration options onto a facade to be applied to all relevant days
*
* @param view View to decorate
*/
void decorate(DayViewFacade view); }

实际使用时,只需实现上述两个方法即可,例如

public class EventDecorator implements DayViewDecorator {

    private final int color;
private final HashSet<CalendarDay> dates; public EventDecorator(int color, Collection<CalendarDay> dates) {
this.color = color;
this.dates = new HashSet<>(dates);
} @Override
public boolean shouldDecorate(CalendarDay day) {
return dates.contains(day);
} @Override
public void decorate(DayViewFacade view) {
view.addSpan(new DotSpan(5, color));
}
}

最新文章

  1. mysql权限管理
  2. GCC-4.6.3编译linux2.6.32.12内核出现“重复的成员‘page’”错误的解决方法
  3. netstat 1
  4. sign in和sign up区别
  5. [ucgui] 对话框7——按钮触发与模式窗口
  6. awt可视化界面上传数据到mysql,jsp通过jdbc方式查询数据库,并将结果打印在网页上
  7. IOS 动画的各种实现方法
  8. kuangbin_ShortPath L (POJ 2502)
  9. 【PSR规范专题(3)】PSR-2 代码风格规范
  10. win8双屏敲代码
  11. HTML&amp;CSS基础学习笔记1.19-DIV标签1
  12. Boost 1.61.0 Library Documentation
  13. 【Android】Android在AlertDialog使用大全
  14. Java 和Oracle的数据类型
  15. DeepLearning.ai学习笔记(四)卷积神经网络 -- week3 目标检测
  16. json和xml的两者区别
  17. js的七大设计原则--迪米特原则
  18. C#中指针使用总结(转载)
  19. 网站性能测试工具 webbench 的安装和使用
  20. LNMP php缓存器下载

热门文章

  1. PMP 第二章 项目生命周期与组织
  2. WPF之MVVM(Step4)&mdash;&mdash;使用Prism(2)
  3. Lingo语法
  4. Linux3.18.6内核添加系统调用(32位系统)
  5. 【java 上传+下载】
  6. Practical JAVA(二)关于对象的类型和equals函数
  7. windows修改虚拟内存
  8. express-2 express介绍
  9. ASP.NET MVC3 中整合 NHibernate3.3、Spring.NET2.0 使用AOP执行事务处理
  10. 疯狂java笔记(七) - Java集合之Map