/Android-Week-Calendar

android可自定义日历方案,支持农历、自定义日历控件、排班、左右滑动、周月切换、跳转到指定日期等功能

Primary LanguageJava

主要特性

  • 设置自定义日期角标
  • 农历切换
  • 左右滑动切换上下周月,上下滑动切换周月模式
  • 抽屉式周月切换效果
  • 标记指定日期(marker)
  • 跳转到指定日期

预览图片

使用方法

在layout中使用:

<com.android.calendarlibrary.CollapseCalendarView
        android:id="@+id/calendar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

使用此方法初始化日历标记数据

mManager = new CalendarManager(LocalDate.now(),
                CalendarManager.State.MONTH,
                LocalDate.now().withYear(100),
                LocalDate.now().plusYears(100));
calendarView.init(mManager);

使用方法设置日历数据

是否显示农历

calendarView.showChinaDay(true);

回到今天

calendarView.changeDate(LocalDate.now().toString());

周月切换

 // TODO Auto-generated method stub
mManager.toggleView();
calendarView.populateLayout();

班排

calendarView.setArrayData(json);
calendarView.populateLayout();

使用方法添加上相关监听

月份切换监听器

mManager.setMonthChangeListener(new CalendarManager.OnMonthChangeListener() {
       @Override
      public void monthChange(String month, LocalDate mSelected) {
      // TODO Auto-generated method stub
      //Toast.makeText(MainActivity.this, month, Toast.LENGTH_SHORT).show();
      }
});

日期选中监听器

calendarView.setDateSelectListener(new CollapseCalendarView.OnDateSelect() {
       @Override
       public void onDateSelected(LocalDate date) {
       // Toast.makeText(MainActivity.this, date.toString(), Toast.LENGTH_SHORT).show();
       }
});

APK

安装 apk 文件预览效果,或者通过下面二维码去下载安装:

DEMO下载二维码

License

Copyright 2017 chenyongci

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.