CalendarView

Additional

Language
Java
Version
N/A
Created
Jun 27, 2016
Updated
Mar 10, 2017 (Retired)
Owner
henry (henry-newbie)
Contributor
henry (henry-newbie)
1
Activity
Badge
Generate
Download
Source code
APK file

Promotion

CalendarView

================

CalendarView是一个高度定制的日期选择器,可以满足多选日期的需求。

集成

该库已上传到Jcenter中, 可以再build.gradle中直接添加

dependencies {
    compile 'com.henry:calendarview:1.1.2'
}

使用

在xml文件中声明DayPickerView

<com.henry.calendarview.DayPickerView
    android:id="@+id/dpv_calendar"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:colorCurrentDay="@color/colorAccent"
    app:colorSelectedDayBackground="@color/colorAccent"
    app:colorSelectedDayText="@color/selected_day_text"
    app:colorPreviousDayText="#727272"
    app:colorNormalDayText="#727272"
    app:colorYearMonthText="#727272"
    app:colorWeekText="#727272"
    app:colorBusyDaysBg="#727272"
    app:colorInValidDaysBg="#727272"
    app:colorBusyDaysText="#FFFFFF"
    app:colorInValidDaysText="#FFFFFF"

    app:textSizeDay="14sp"
    app:textSizeTag="12sp"
    app:textSizeYearMonth="16sp"
    app:textSizeWeek="14sp"
    app:headerMonthHeight="50dp"
    app:selectedDayRadius="20dp"
    app:calendarHeight="320dp"
    app:enablePreviousDay="false"/>

然后在你的代码中设置DataModel(参数集),DatePickerController(回调接口)

    DayPickerView.DataModel dataModel = new DayPickerView.DataModel();
    dataModel.yearStart = 2016;
    dataModel.monthStart = 6;
    dataModel.monthCount = 16;
    dataModel.defTag = "¥100";
    dataModel.leastDaysNum = 2;
    dataModel.mostDaysNum = 100;

 dayPickerView.setParameter(dataModel, new DatePickerController() {
        @Override
        public void onDayOfMonthSelected(SimpleMonthAdapter.CalendarDay calendarDay) {
            Toast.makeText(context, "onDayOfMonthSelected", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onDateRangeSelected(List<SimpleMonthAdapter.CalendarDay> selectedDays) {
            Toast.makeText(context, "onDateRangeSelected", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void alertSelectedFail(FailEven even) {
            Toast.makeText(context, "alertSelectedFail", Toast.LENGTH_SHORT).show();
        }
    });

onDayOfMonthSelected(SimpleMonthAdapter.CalendarDay calendarDay); 点击日期回调函数

onDateRangeSelected(List<SimpleMonthAdapter.CalendarDay> selectedDays); 选择日期范围回调函数

alertSelectedFail(FailEven even); 异常回调函数