Home

Awesome

CalendarRangeSelect

Android日历连续区间选择

效果预览

image

Gradle配置

allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}
	
	dependencies {
	        compile 'com.github.TurnTears:CalendarRangeSelect:1.1.1'
	}

基本使用

 <com.muzi.calendarrangeselect.widget.CalendarView
        android:id="@+id/calendarView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
 calendarView = (CalendarView) findViewById(R.id.calendarView);
        
//必须在setOnCalendarSelect()之前
calendarView.setMonthNum(12);

//回调
calendarView.setOnCalendarSelect(new CalendarView.onCalendarSelect() {
      @Override
      public void OnMonthSwhit(MonthTimeEntity entity) {
           textView.setText(entity.toString());
       }

       @Override
       public void OnDaySelect(DayTimeEntity startDay, DayTimeEntity endDay, int day) {
           Toast.makeText(Main2Activity.this, "开始时间:"
                        + startDay.toString() + "\n结束时间:"
                        + endDay.toString() + "\n共"
                        + day + "天", Toast.LENGTH_SHORT).show();

           startTime.setText(startDay.getMonth() + "月" + startDay.getDay() + "日" + "\n");
            stopTime.setText(endDay.getMonth() + "月" + endDay.getDay() + "日");
       }
      });
      
@Override
    protected void onDestroy() {
        super.onDestroy();
        calendarView.onDestory();
    }      

CalendarView基本功能介绍

 calendarView.setMonthNum(12);
 calendarView.setUnableSelectDay(2);
 calendarView.setMultipleChoice(6);

感谢