Home

Awesome

WeekCalendar

周日历,Weekly Calendar。

效果图

使用方法(usage)

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

	allprojects {
		repositories {
			...
			maven { url "https://jitpack.io" }
		}
	}

Step 2. Add the dependency

	dependencies {
	    compile 'com.github.loonggg:WeekCalendar:v1.4'
	}

Step 3. There are a few xml attributes to customise the calendar

Example

 <com.loonggg.weekcalendar.view.WeekCalendar
        android:id="@+id/week_calendar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#ffffff"
        android:paddingBottom="10dp"
        app:cornerMarkBg="@mipmap/order_book_icon"
        app:daysSelectedBackground="@drawable/green_oval_bg"
        app:isCornerMark="true"
        app:monthBackgroundColor="#8F83F1"
        app:nextArrowBg="@mipmap/white_right_arrow"
        app:preArrowBg="@mipmap/white_left_arrow" />

Step 4. Impelement Listener

weekCalendar = (WeekCalendar) findViewById(R.id.week_calendar);
List<String> list = new ArrayList<>();
list.add("2016-09-13");
list.add("2016-10-13");
list.add("2016-10-11");
list.add("2016-10-10");
list.add("2016-10-16");
//传入已经预约或者曾经要展示选中的时间列表
weekCalendar.setSelectDates(list);
//设置日历点击事件
weekCalendar.setOnDateClickListener(new WeekCalendar.OnDateClickListener() {
     @Override
     public void onDateClick(String time) {
         Toast.makeText(MainActivity.this, time, Toast.LENGTH_SHORT).show();
     }
});
//设置年月时间的回调
weekCalendar.setOnCurrentMonthDateListener(new WeekCalendar.OnCurrentMonthDateListener() {
     @Override
     public void onCallbackMonthDate(String year, String month) {
         Toast.makeText(MainActivity.this, year + "-" + month, Toast.LENGTH_SHORT).show();
     }
});

公众号

欢迎大家关注我的微信公众号:非著名程序员(smart_android),更多好的原创文章均首发于微信订阅号:非著名程序员

License

Copyright 2016 loonggg

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.