diff --git a/README.md b/README.md index 5e26494..3f49ad2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # WeekCalendar 周日历,Weekly Calendar。 +## 效果图 + ## 使用方法(usage) ### Step 1. Add the JitPack repository to your build file @@ -17,7 +19,7 @@ Add it in your root build.gradle at the end of repositories: ### Step 2. Add the dependency ```java dependencies { - compile 'com.github.loonggg:WeekCalendar:v1.0' + compile 'com.github.loonggg:WeekCalendar:v1.1' } ``` @@ -54,6 +56,23 @@ Add it in your root build.gradle at the end of repositories: app:nextArrowBg="@mipmap/white_right_arrow" app:preArrowBg="@mipmap/white_left_arrow" /> ``` - - + ### Step 4. Impelement Listener + ```java + weekCalendar = (WeekCalendar) findViewById(R.id.week_calendar); + List 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(); + } + }); + ``` diff --git a/app/src/main/java/com/loonggg/weekcalendar/test/MainActivity.java b/app/src/main/java/com/loonggg/weekcalendar/test/MainActivity.java index 6a5d069..05cb066 100644 --- a/app/src/main/java/com/loonggg/weekcalendar/test/MainActivity.java +++ b/app/src/main/java/com/loonggg/weekcalendar/test/MainActivity.java @@ -3,7 +3,6 @@ import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; -import android.view.View; import android.widget.TextView; import android.widget.Toast; @@ -21,7 +20,7 @@ public class MainActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - weekCalendar = (WeekCalendar) findViewById(R.id.mc_calendar); + weekCalendar = (WeekCalendar) findViewById(R.id.week_calendar); List list = new ArrayList<>(); list.add("2016-09-13"); list.add("2016-10-13"); @@ -32,8 +31,8 @@ protected void onCreate(Bundle savedInstanceState) { //设置日历点击事件 weekCalendar.setOnDateClickListener(new WeekCalendar.OnDateClickListener() { @Override - public void onDateClick(View view, int position) { - Toast.makeText(MainActivity.this, weekCalendar.getTheDayOfSelected(), Toast.LENGTH_SHORT).show(); + public void onDateClick(String time) { + Toast.makeText(MainActivity.this, time, Toast.LENGTH_SHORT).show(); } }); diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 9ac2a3b..7fa3184 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -6,7 +6,7 @@ android:layout_height="match_parent">