[android-developers] setMinDate(…) for DatePicker doesn't work when invoked a second time
I'm in a particular situation in which I have to alter the min and max date of DatePicker according to the selected element of a Spinner. Here's the chunk of code I'm using to switch min and max date.
private void switchCalculationMethod(int method) {
calculationMethod = method;
switch (method) {
case METHOD_1:
datePicker.setMinDate(new LocalDate().minusWeeks(42).toDateTimeAtStartOfDay()
.getMillis());
datePicker.setMaxDate(new LocalDate().plusDays(1).toDateTimeAtStartOfDay()
.getMillis() - 1);
break;
case METHOD_2:
datePicker.setMinDate(new LocalDate().minusWeeks(2).toDateTimeAtStartOfDay()
.getMillis()); // This don't work!!
datePicker.setMaxDate(new LocalDate().plusWeeks(40).toDateTimeAtStartOfDay()
.getMillis()); // This works!!!
break;
}
datePicker.init(today.getYear(), today.getMonthOfYear() - 1,
today.getDayOfMonth(), this);
}
So, the DatePicker would get set up correctly the first time, problem occurs when I attempt to change the min date again (changing max date works). It would remain at the value I had set first. I'm thinking this is a bug (would be great if this can be confirmed). But I thought I'd post it here because I might be doing something wrong.
PS : I'm using Joda time api.
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home