Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

反馈遇到的问题和建议 #22

Closed
JoviLam opened this issue Oct 31, 2017 · 1 comment
Closed

反馈遇到的问题和建议 #22

JoviLam opened this issue Oct 31, 2017 · 1 comment

Comments

@JoviLam
Copy link

JoviLam commented Oct 31, 2017

CalendarCardView.STYLE_FILL or CalendarCardView.STYLE_STROKE
定义的是包访问级别,在项目中无法使用,只能写1和2。
功能比较少,翻页没有事件监听
未提供动态以月为单位切换视图,仅提供根据年份切换。
只能自己继承反射实现,希望作者下一版本能加上。

public class VCalendarView extends CalendarView {
private WrapViewPager mViewPager;
private static int mMinYear, mMaxYear;
private Calendar selectCalendar;

public VCalendarView(@NonNull Context context) {
    super(context);
}

public VCalendarView(@NonNull Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    TypedArray array = context.obtainStyledAttributes(attrs, com.haibin.calendarview.R.styleable.CalendarView);
    mMinYear = array.getInt(com.haibin.calendarview.R.styleable.CalendarView_min_year, 2010);
    mMaxYear = array.getInt(com.haibin.calendarview.R.styleable.CalendarView_max_year, 2050);
    if (mMinYear <= 1900) mMaxYear = 1900;
    if (mMaxYear >= 2099) mMaxYear = 2099;
    try {
        Field field = getClass().getSuperclass().getDeclaredField("mViewPager");
        field.setAccessible(true);
        mViewPager = (WrapViewPager) field.get(this);

    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    selectCalendar = super.getSelectedCalendar();
}

/**
 * 滚动到某月
 *
 * @param year
 * @param month
 */
public void scrollToMonth(int year, int month) {
    mViewPager.setCurrentItem(12 * (year - mMinYear) + month - 1);
}

}

@huanghaibin-dev
Copy link
Owner

@JoviLam 全新版本已经开源

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants