Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] android – DatePickerDialog resets to default month when changing selectableDays

Posted on November 11, 2022 By

Solution 1 :

By checking the code here

https://github.com/wdullaer/MaterialDateTimePicker/blob/f849a5c2704c974ba182fe4e2e205fa7f4fd395d/library/src/main/java/com/wdullaer/materialdatetimepicker/date/DatePickerDialog.java#L846

It seems that after you set new selectableDays, the refresh function will take current selected day position and scroll back to it https://github.com/wdullaer/MaterialDateTimePicker/blob/f849a5c2704c974ba182fe4e2e205fa7f4fd395d/library/src/main/java/com/wdullaer/materialdatetimepicker/date/DayPickerView.java#L142

So my proposal will be setting the mSelectedDay to the first day of the month when user scoll to the next month. Which I think also not a great user experience.

I would also recommend to post this question on author’s github page, or search for similar question/issue/bug history in the library github pag

Problem :

I have a DatePickerDialog (com.wdullaer.materialdatetimepicker.date) that has its selectableDays populated from an API.
The API that we use only supports retrieving one month at a time. As a result, we need to retrieve more selectableDays for the next month when the user taps the arrow to go to the next month. (Circled in red in the attached image)

Arrow To Change Months

We accomplish this by keeping a global list of calendars and adding additional Calendars from the network responses:

val selectableCalendars = HashSet<Calendar>() // List of available appointment dates (including time)

That works fine, but when DatePickerDialog is open and the following line runs to change the selectable days:

datePickerDialog.selectableDays = selectableCalendars.toTypedArray()

The DatePickerDialog will jump back to the first month in the calendar list.

This “jump back to June” (unintended behavior) always occurs under the following circumstances:

1.) Immediately after we set datePickerDialog.selectableDays to a new value.

2.) Only if there are no selectable days for the month the user scrolled into. (Bug does not occur if there are selectable days in the
returned month!)

Does anyone have a workaround for this issue?

READ  [FIXED] Foursquare Autocomplete API explorer response different from android app response
Powered by Inline Related Posts

Comments

Comment posted by opened an issue on their github page

As recommended, I

Android Tags:android, materialdatepicker

Post navigation

Previous Post: [FIXED] android – W/Firestore: (24.1.2) [CustomClassMapper]: No setter/field for about found on class
Next Post: [FIXED] android – FusedLocationProviderClient and LocationCallback() object queries

Related Posts

[FIXED] android studio – How to access the Camera itself in Flutter/Dart? Android
[FIXED] need to convert following Signnature verification python code to Android? Android
[FIXED] java – How to listen for lottie animation end from activity Android
[FIXED] android – findViewById returns null for a ScrollView Android
[FIXED] android – Limiting google prediction to a specific country doesn’t work Android
[FIXED] java – get arrayList value into ArrayAdapter for a listView in android studio Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • Can VPN be traced by police?
  • Where were Kaiser-Frazer cars built?
  • How do you make gold rose gold paint?
  • What are the newest type of dentures?
  • Can you wear joggers as dress pants?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme