1、Gradle直接引用项目library类库。

compile 'com.dsw.calendar:library:1.0.0'

2、布局里面加入自定义日历控件

<com.dsw.calendar.views.GridCalendarView
android:id="@+id/gridMonthView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >

</com.dsw.calendar.views.GridCalendarView>

3、获取控件ID

GridCalendarView gridCalendarView = (GridCalendarView) findViewById(R.id.gridMonthView);

4、绑定日历上的点击事件。点击日历某日显示年月日信息。根据需求(我这边所用的需求),可获取该数据用于提交

gridCalendarView.setDateClick(new MonthView.IDateClick() {//点击日期显示年月日
@Override
public void onClickOnDate(int year, int month, int day) {
Toast.makeText(Atycalendar.this, "点击了" + year + "-" + month + "-" + day, Toast.LENGTH_SHORT).show();
}
});

List<CalendarInfo> list = new ArrayList<CalendarInfo>();// 写上之后初始日期不会错乱,本来是用于添加内容的代码
gridCalendarView.setCalendarInfos(list);//重点是这,重新设置日历信息的时候它的界面信息就是新的、正确的。

5、注:最后面两行代码没有的话日历初始显示的时间会出错。