Cannot Programmatically Select Last Date In Range
See original GitHub issueDisclaimer: I am writing my app in Kotlin
For my app I need the last date in my range to be the current date, and for the current date to be the default selection when the view loads. When I provide the current date as the endDate for the calendar, the calendar selects the first date in the range as the default.
val startDate = Calendar.getInstance()
startDate.add(Calendar.MONTH, -1)
val endDate = Calendar.getInstance()
datePicker = HorizontalCalendar.Builder(activity, R.id.calendarView)
.range(startDate, endDate)
.datesNumberOnScreen(7)
.build()
When the view loads, the calendar has selected the first date in the range. I have also tried adding the following after the above code:
datePicker?.selectDate(Calendar.getInstance(), true)
datePicker?.goToday(true)
as well as adding the following to my build chain:
.defaultSelectedDate(Calendar.getInstance())
and none of those did the trick. if I increase the endDate by a single day everything works fine.
I am still able to manually select the final date in the range, everything still works fine with manual selection.
I saw in an old thread there had been issues with the number of dates displayed, and I tried changing that to 5. This also had no effect.
Thanks in advance!
Steps to Reproduce the Problem (sample code if possible)
- Initialize a
HorizontalCalendar
withCalendar.getInstance()
as the end date.
Specifications
- Android Version: 26
- Horizontal-Calendar Version: 1.3.0
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (5 by maintainers)
Top GitHub Comments
@Mulham-Raee I upgraded to 1.3.4 and I still have this behavior. The last date (today) is automatically selected when the view loads, but If I select another date and then select the last date (today) again, the ui shows my selection but
onDateSelected
is not invoked.Here’s my setup for your reference
Please let me know if there’s any other info you would find helpful.
Thanks!
Yes this is probably related to the same problem, thanks for pointing it out.