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

日历范围选择器 #290

Closed
YQcharlse opened this issue Jan 27, 2022 · 3 comments
Closed

日历范围选择器 #290

YQcharlse opened this issue Jan 27, 2022 · 3 comments
Labels

Comments

@YQcharlse
Copy link

YQcharlse commented Jan 27, 2022

你好,有一个问题,就是我的日期范围是去年到今天的,但是在选择范围的时候,会记录上次选择的范围,每次赋值默认选择的日期范围,选择有1号的时候 ,打开没有跳转到当前选择的范围,而是到了开始的日期。

@chen2tu
Copy link

chen2tu commented Aug 17, 2022

同样碰到了,问题原因是:
CalendarAdapter 中,getDatePosition 方法的
for (int i = 0; i <= lastPosition; i++) { Calendar minDate = DateUtils.calendar(dates.get(i).getTime()); minDate.set(Calendar.DAY_OF_MONTH, 1); minDate.set(Calendar.HOUR_OF_DAY, 0); minDate.set(Calendar.MINUTE, 0); minDate.set(Calendar.SECOND, 0); Calendar maxDate = DateUtils.calendar(dates.get(i).getTime()); maxDate.set(Calendar.DAY_OF_MONTH, DateUtils.maxDaysOfMonth(maxDate.getTime())); maxDate.set(Calendar.HOUR_OF_DAY, 23); maxDate.set(Calendar.MINUTE, 59); maxDate.set(Calendar.SECOND, 59); if (time >= minDate.getTime().getTime() && time <= maxDate.getTime().getTime()) { return i; } }

代码中算法有问题。

如果不想拉代码下来修改的话,使用者在设置日历回显的时候,startDate + 1000ms 就可以规避这个问题了。

@YQcharlse

@YQcharlse
Copy link
Author

好的谢谢。

@hexin9456
Copy link

你好 问一下 设置回显是哪个方法呢?使用的是CalendarPicker

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

No branches or pull requests

4 participants