Coder Social home page Coder Social logo

calendarrangeselect's Introduction

CalendarRangeSelect

Android日历连续区间选择

效果预览

image

Gradle配置

  • Step 1. build.gradle(Project:***)添加
allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}
	
  • Step 2. build.gradle(Module:app)
	dependencies {
	        compile 'com.github.TurnTears:CalendarRangeSelect:1.1.1'
	}

基本使用

  • 1、布局文件
 <com.muzi.calendarrangeselect.widget.CalendarView
        android:id="@+id/calendarView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
  • 2、Activity
 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基本功能介绍

  • 设置日历显示的月份数量默认为6个月
 calendarView.setMonthNum(12);
  • 设置不可点击的天数, 从今天以后开始计算,在途状态不可点击
 calendarView.setUnableSelectDay(2);
  • 设置连续选择
 calendarView.setMultipleChoice(6);

感谢

calendarrangeselect's People

Contributors

doutuifei avatar

Watchers

xiangyutian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.