Note that there are some explanatory texts on larger screens.

plurals
  1. PODatepicker not being updated
    primarykey
    data
    text
    <p>So here's something weird.</p> <p>I have 3 elements: An <code>EditText</code>, a <code>Spinner</code> and a <code>DatePicker</code>. Whenever a value in <code>TextEdit</code> changes or when a <code>Spinner</code> value is selected, the <code>DatePicker</code> gets updated accordingly. Specifically, the <code>Spinner</code> has the choice of Months/Weeks/Days, so the <code>DatePicker</code> updates X weeks/days/months depending on the value in <code>EditText</code>. Simple enough... but I'm getting some very odd behaviour.</p> <p>I have a listener on spinner &amp; text field that invokes a static <code>updateDatePicker()</code> method on any change. Everything works fine on the text field change but for the spinner whenever I update from index 0 to index 2 (from months to days), the date picker does NOT get updated - it stays the same date. The odd thing is, if I go from 0 to 1 to 2, or 2 to 1 to 0 it works and any transition to/from index 1 works. I don't check for any special transitions, the <code>updateDatePicker()</code> method simlply does a switch case on the <code>selectedIndexPosition</code> of the spinner and does it's work accordingly.</p> <p>I know the actual calculation is correct because I can print out the new date I want but it's just the datepicker that's not getting updated. Here is my Logcat and the gode that generates the logcat (where the extra "swapped" tag is just called when the method is called):</p> <pre><code> Log.d("Updated Retest Date:", newDate.get(Calendar.YEAR) + " " + (newDate.get(Calendar.MONTH)-1) + " " + newDate.get(Calendar.DATE)); // Month is starting from 0 hence -1 on the Month datePicker.updateDate(newDate.get(Calendar.YEAR), (newDate.get(Calendar.MONTH)-1), newDate.get(Calendar.DATE)); Log.d("New Date:", datePicker.getYear() + " " + datePicker.getMonth() + " " + datePicker.getDayOfMonth()); 12-03 13:42:56.240: D/DASDSAD(22299): swapped 12-03 13:42:56.240: D/Item Position Spinner(22299): 0 12-03 13:42:56.240: D/Updated Retest Date:(22299): 2013 9 8 12-03 13:42:56.250: D/New Date:(22299): 2013 9 8 12-03 13:43:00.140: D/DASDSAD(22299): swapped 12-03 13:43:00.140: D/Item Position Spinner(22299): 1 12-03 13:43:00.140: D/Updated Retest Date:(22299): 2013 8 15 12-03 13:43:00.160: D/New Date:(22299): 2013 8 15 12-03 13:43:01.985: D/DASDSAD(22299): swapped 12-03 13:43:01.990: D/Item Position Spinner(22299): 2 12-03 13:43:01.990: D/Updated Retest Date:(22299): 2013 8 9 12-03 13:43:02.000: D/New Date:(22299): 2013 8 9 12-03 13:43:03.625: D/DASDSAD(22299): swapped 12-03 13:43:03.625: D/Item Position Spinner(22299): 1 12-03 13:43:03.625: D/Updated Retest Date:(22299): 2013 8 15 12-03 13:43:03.630: D/New Date:(22299): 2013 8 15 12-03 13:43:04.900: D/DASDSAD(22299): swapped 12-03 13:43:04.905: D/Item Position Spinner(22299): 0 12-03 13:43:04.905: D/Updated Retest Date:(22299): 2013 9 8 12-03 13:43:04.915: D/New Date:(22299): 2013 9 8 12-03 13:43:06.255: D/DASDSAD(22299): swapped 12-03 13:43:06.260: D/Item Position Spinner(22299): 2 12-03 13:43:06.260: D/Updated Retest Date:(22299): 2013 8 9 12-03 13:43:06.260: D/New Date:(22299): 2013 9 8 </code></pre> <p>As you can see on the last 3 lines, I get 2013 8 9 as the new date, update the datepicker with it and query the datepicker's new date but it still gives me 2013 9 8. </p> <p>Thanks, I've been going crazy over this.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload