I have an android Dialog
with a 3 numberpickers
inside. Changing the 3rd picker triggers a change in the displayed values of the first 2 pickers
. However I've noticed when I change the displayed values, and call
setWrapSelectorWheel(false)
it still shows the new values as wrapped visually (I can see the last value above the first one).
If I touch the picker it suddenly snaps into non wrap selector wheel. What's odd is I call
getWrapSelectoWheel()
after setting the displayed values and it returns false... just like I set it. But visually it's wrong.
Any ideas what's going on?
Many thanks!
I found a solution, Daniel was on the right track, however it appears that initializeSelectorWheelIndices
is actually a bad thing once you've already set your values. Because of this, you need to call setMinValue
and setMaxValue
BEFORE you set your values. However, if you already have an array set on your picker, if you call setMaxValue
with a higher value than the current array, it will give you a ArrayIndexOutOfBounds
exception.
The solution then is to clear the old display values, set your max value, then you can call setWrapSelectorWheel
and setDisplayValues
:
public void updatePickerValues(String[] newValues){
picker.setDisplayedValues(null);
picker.setMinValue(0);
picker.setMaxValue(newValues.length -1);
picker.setWrapSelectorWheel(false);
picker.setDisplayedValues(newValues);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With