JS 与 trick 代码的运用及解析全攻略
705
2022-11-03
仿小米android周日历视图
sample-of-Android-week-view
week header viewweek day viewadd eventsHorizontal and vertical scrolling.
Usage
Import the library into your project.Add WeekHeaderView and WeekDayView in your xml layout.
Write the following code in your java file. mWeekView = (WeekDayView) findViewById(R.id.weekdayview); mWeekHeaderView= (WeekHeaderView) findViewById(R.id.weekheaderview); mTv_date =(TextView)findViewById(R.id.tv_date); mWeekView.setMonthChangeListener(this); mWeekView.setEventLongPressListener(this); mWeekView.setOnEventClickListener(this); mWeekView.setScrollListener(this); mWeekHeaderView.setDateSelectedChangeListener(new WeekHeaderView.DateSelectedChangeListener() { @Override public void onDateSelectedChange(Calendar oldSelectedDay, Calendar newSelectedDay) { mWeekView.goToDate(newSelectedDay); } }); mWeekHeaderView.setScrollListener(new WeekHeaderView.ScrollListener() { @Override public void onFirstVisibleDayChanged(Calendar newFirstVisibleDay, Calendar oldFirstVisibleDay) { mWeekView.goToDate(mWeekHeaderView.getSelectedDay()); } }); Implement WeekDayView.MonthChangeListener, WeekDayView.EventClickListener, WeekDayView.EventLongPressListener according to your need. Provide the events for the WeekDayView in WeekDayView.MonthChangeListener.onMonthChange() callback. Please remember that the calendar pre-loads events of three consecutive months to enable lag-free scrolling.WeekView.MonthChangeListener mMonthChangeListener = new WeekView.MonthChangeListener() { @Override public List
You can customize the look of the WeekHeaderView in xml. Use the following attributes in xml. All these attributes also have getters and setters to enable you to change the style dynamically.
firstDayOfWeek2headerWeekLabelTextSizeheaderDayLabelTextSizeheaderWeekLabelTextColorheaderDayLabelNormalTextColorheaderDayLabelTodayTextColorheaderBackgroundColorheaderRowGapheaderPaddingLeftheaderPaddingRightheaderPaddingTopheaderPaddingBottomheaderFocusTextColorheaderFocusBackgroundColorheaderFocusSameDayBackgroundColorheaderFocusSameDayTextColor
You can customize the look of the WeekDayView in xml. Use the following attributes in xml. All these attributes also have getters and setters to enable you to change the style dynamically.
columnGapdayBackgroundColordayNameLengtheventMarginVerticaleventPaddingeventTextColoreventTextSizefirstDayOfWeekheaderColumnBackgroundheaderColumnPaddingheaderColumnTextColorheaderRowBackgroundColorheaderRowPaddinghourHeighthourSeparatorColorhourSeparatorHeightnoOfVisibleDaysoverlappingEventGaptextSizetodayBackgroundColortodayHeaderTextColor
Interfaces
Use the following interfaces according to your need.
mWeekView.setMonthChangeListener() to provide events to the calendarmWeekView.setOnEventClickListener() to get a callback when an event is clickedmWeekView.setEventLongPressListener() to get a callback when an event is long pressedmWeekView.setEmptyViewClickListener() to get a callback when any empty space is clickedmWeekView.setEmptyViewLongPressListener() to get a callback when any empty space is long pressedmWeekView.setDateTimeInterpreter() to set your own labels for the calendar header row and header columnmWeekView.setScrollListener() to get an event every time the first visible day has changed
Thank you alamkanak
Android-week-view
If you have any question,you can send email to guojunustb@163.com
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~