以周格式显示数据的Android视图 - WeekViewSwipeable

2016-10-10      51      Android
项目简介

WeekViewSwipeable

WeekViewSwipeable是一个以周格式显示数据的简单的Android视图。给定一个数据列表,最后一个元素绑定到当前日历天,前一天绑定到昨天,等等。只需覆盖适配器即可自定义需要的天数环形。

使用方法

<com.yuncun.swipeableweekview.WeekViewSwipeable
        android:id="@+id/calendar_component"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        app:circleDefaultFillColor="@color/grey_500"
        app:circleDefaultStrokeColor="@color/grey_500"
        app:circleDefaultTextColor="@color/grey_750"
        />

将数据放入 WeekViewAdapter,并重写需要自定义的函数。

List<Boolean> data = Arrays.asList(true, false); //Example set; use your own List<T> here
WeekViewSwipeable wvs = (WeekViewSwipeable) findViewById(R.id.calendar_component);
WeekViewAdapter<Boolean> adapter = new WeekViewAdapter(data) {
    @Override
    public int getStrokeColor(final int index){
        //Override this to change circle stroke color
    }

    @Override
    public int getFillColor(final int index){
        //Override to change circle fill color
    }

    @Override
    public TextView getTextView(TextView tv, int index){
        //Gives you access to TextView
        return tv;
    }

    @Override
    public CircleView getCircleView(CircleView cv, int index){
        //Gives you access to CircleView
        return cv;
    }

    @Override
    public View getDayLayout(View dv, final int index){
        //Returns entire dayview. This could be useful for setting an onclicklistener, for example
        return dv;
    }
};
wvs.setAdapter(adapter);

下载

Gradle:

compile 'com.yuncun.weekviewswipeable:weekviewswipeable:1.0.0'