MaterialCalendarView使用时遇到的问题
2024-08-24 15:01:16
一、概述
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));
}
}
最新文章
- mysql权限管理
- GCC-4.6.3编译linux2.6.32.12内核出现“重复的成员‘page’”错误的解决方法
- netstat 1
- sign in和sign up区别
- [ucgui] 对话框7——按钮触发与模式窗口
- awt可视化界面上传数据到mysql,jsp通过jdbc方式查询数据库,并将结果打印在网页上
- IOS 动画的各种实现方法
- kuangbin_ShortPath L (POJ 2502)
- 【PSR规范专题(3)】PSR-2 代码风格规范
- win8双屏敲代码
- HTML&;CSS基础学习笔记1.19-DIV标签1
- Boost 1.61.0 Library Documentation
- 【Android】Android在AlertDialog使用大全
- Java 和Oracle的数据类型
- DeepLearning.ai学习笔记(四)卷积神经网络 -- week3 目标检测
- json和xml的两者区别
- js的七大设计原则--迪米特原则
- C#中指针使用总结(转载)
- 网站性能测试工具 webbench 的安装和使用
- LNMP php缓存器下载
热门文章
- PMP 第二章 项目生命周期与组织
- WPF之MVVM(Step4)&mdash;&mdash;使用Prism(2)
- Lingo语法
- Linux3.18.6内核添加系统调用(32位系统)
- 【java 上传+下载】
- Practical JAVA(二)关于对象的类型和equals函数
- windows修改虚拟内存
- express-2 express介绍
- ASP.NET MVC3 中整合 NHibernate3.3、Spring.NET2.0 使用AOP执行事务处理
- 疯狂java笔记(七) - Java集合之Map