Skip to content

Commit

Permalink
增加了是否显示年月一栏的属性
Browse files Browse the repository at this point in the history
  • Loading branch information
loonggg committed Oct 13, 2016
1 parent ec2bc03 commit 4099582
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 58 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,59 @@
# WeekCalendar
周日历
周日历,Weekly Calendar。

## 使用方法(usage)
### Step 1. Add the JitPack repository to your build file
```java
Add it in your root build.gradle at the end of repositories:

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

### Step 2. Add the dependency
```java
dependencies {
compile 'com.github.loonggg:WeekCalendar:v1.0'
}
```

### Step 3. There are a few xml attributes to customise the calendar
* daysTextSize 设置日期中“天day”的文字大小
* todayTextColor 设置日期中当天文字的颜色
* daysTextColor 设置日期中“天day”的文字颜色
* daysSelectedTextColor 设置选中的日期的文字颜色
* daysSelectedBackground 设置选中的日期的背景
* weekTextSize 设置星期栏的字体大小
* weekTextColor 设置星期一栏中的字体颜色
* weekBackgroundColor 设置星期一烂背景
* hideTodayName 是否显示当天日期时的日期为“今”字,否则显示日期数字
* isCornerMark 是否显示选中的日期中的右上角的角标
* cornerMarkBg 设置角标图片
* monthBackgroundColor 设置年月栏的背景色
* monthTextColor 设置年月字体颜色
* nextArrowBg 设置年月栏下一个月的按钮背景
* preArrowBg 设置上一个月的按钮背景
* isShowMonth 是否显示年月一栏

#### Example
```xml
<com.loonggg.weekcalendar.view.WeekCalendar
android:id="@+id/mc_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" />
```



Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@
public class MainActivity extends AppCompatActivity {
Toolbar mToolbar;
TextView mTvTitle;//标题
WeekCalendar mMcCalendar;//自定义日历控件
WeekCalendar weekCalendar;//自定义日历控件

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mMcCalendar = (WeekCalendar) findViewById(R.id.mc_calendar);
weekCalendar = (WeekCalendar) findViewById(R.id.mc_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");
mMcCalendar.setSelectDates(list);
weekCalendar.setSelectDates(list);
//设置日历点击事件
mMcCalendar.setOnItemClickLitener(new WeekCalendar.OnItemClickLitener() {
weekCalendar.setOnDateClickListener(new WeekCalendar.OnDateClickListener() {
@Override
public void onItemClick(View view, int position) {
Toast.makeText(MainActivity.this, mMcCalendar.getTheDayOfSelected(), Toast.LENGTH_SHORT).show();
public void onDateClick(View view, int position) {
Toast.makeText(MainActivity.this, weekCalendar.getTheDayOfSelected(), Toast.LENGTH_SHORT).show();
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class WeekCalendar extends LinearLayout {

private Context context;
private GridView mGridView = null;
private OnItemClickLitener mOnItemClickLitener;
private OnDateClickListener listener;

private List<CalendarData> calendarDatas;
private Map<Integer, List> weeks;
Expand Down Expand Up @@ -369,8 +369,8 @@ public void onClick(View v) {
theDayOfSelected = datas.get(position);
theDayForShow = datas.get(position);
notifyDataSetChanged();
if (mOnItemClickLitener != null) {
mOnItemClickLitener.onItemClick(dayView, position);
if (listener != null) {
listener.onDateClick(dayView, position);
}
}
});
Expand All @@ -380,17 +380,17 @@ public void onClick(View v) {


/**
* ItemClick的回调接口
* 点击选中日期的回调接口
*/
public interface OnItemClickLitener {
void onItemClick(View view, int position);
public interface OnDateClickListener {
void onDateClick(View view, int position);
}

/**
* 设置回调接口
*/
public void setOnItemClickLitener(OnItemClickLitener mOnItemClickLitener) {
this.mOnItemClickLitener = mOnItemClickLitener;
public void setOnDateClickListener(OnDateClickListener listener) {
this.listener = listener;
}

/**
Expand Down

0 comments on commit 4099582

Please sign in to comment.