datepicker-timeline
介绍:
一个横向滚动的单排日期选择器
运行效果:
使用说明:
首先添加jitpack:
repositories {
// ...
maven { url "https://jitpack.io" }
}
然后添加该库的依赖:
compile 'com.github.badoualy:datepicker-timeline:c6dcd05737'
添加view
<com.github.badoualy.datepicker.DatePickerTimeline
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
设置第一个可见的日期
timeline.setFirstVisibleDate(2016, Calendar.JULY, 19);
设置日期范围
timeline.setLastVisibleDate(2020, Calendar.JULY, 19);
Supply a label adapter to add a label below each date if needed
timeline.setDateLabelAdapter(new MonthView.DateLabelAdapter() {
@Override
public CharSequence getLabel(Calendar calendar, int index) {
return Integer.toString(calendar.get(Calendar.MONTH) + 1) + "/" + (calendar.get(Calendar.YEAR) % 2000);
}
});
设置选中日期的监听者
timeline.setOnDateSelectedListener(new DatePickerTimeline.OnDateSelectedListener() {
@Override
public void onDateSelected(int year, int month, int day, int index) {
}
});
也可以手动设置日期
timeline.setSelectedDate(2017, Calendar.JULY, 19);
已下载
0