Sunday, 26 January 2014

Android: NumberPicker - calling setWrapSelectorWheel(false) does nothing!!

In case you're using a NumberPicker instance, you have a good range of min-max values and you're calling NumberPicker.setWrapSelectorWheel(false) but it isn't disabling wrapping around the min/max values, it could be a simple issue of re-ordering your method calls. So, this won't work...

numberPicker.setWrapSelectorWheel(false);
numberPicker.setMinValue(0);
numberPicker.setMaxValue(10);
numberPicker.setValue(5);

... but this will...

numberPicker.setMinValue(0);
numberPicker.setMaxValue(10);
numberPicker.setValue(5);
numberPicker.setWrapSelectorWheel(false);

The key is to call NumberPicker.setWrapSelectorWheel(false) after you've set your NumberPicker's min and max values.

1 comment:

Boris Godin said...

Thanks, finally I made it work!