FloatingActionButton (开源日历)

使用步骤

1、导入依赖

 implementation 'com.prolificinteractive:material-calendarview:1.4.3'

2、Activity/xml 中引用(按钮)

   

3、Activity 跳转到CalendarActivity页面

4、CalendarActivity /xml点击(2中按钮) 跳转的日历界面


4、CalendarActivity 中

public class CalendarActivity extends BaseActivity {


    @BindView(R.id.mc)
    MaterialCalendarView mc;
    @BindView(R.id.tv_calendar)
    TextView tvCalendar;
    private CalendarDay mDate;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_calendar;
    }

    @Override
    protected void initView() {
        super.initView();
        mc.state().edit()
                .setFirstDayOfWeek(Calendar.SUNDAY)
                .setMinimumDate(CalendarDay.from(2018,4,20))
              .setMaximumDate(CalendarDay.from(DateUtil.getCurrentYear(),DateUtil.getCurrentMonth(),DateUtil.getCurrentDay()))
                .setCalendarDisplayMode(CalendarMode.MONTHS)
                .commit();
        mc.setOnDateChangedListener(new OnDateSelectedListener() {
            @Override
            public void onDateSelected(@NonNull MaterialCalendarView widget, @NonNull CalendarDay
                    date, boolean selected) {
                mDate = date;
            }
        });
    }

    @OnClick(R.id.tv_calendar)
    public void onClick() {
        if (mDate!=null){
            EventBus.getDefault().post(mDate);
            finish();
        }
    }
}

你可能感兴趣的:(FloatingActionButton (开源日历))