I have a NumberPicker that has a formatter that formats the displayed numbers either by rotating the NumberPicker or by manually entering a value. This works fine, but when NumberPicker is displayed first, and I initialize it with setValue(0) , 0 is not formatted (it should display as "-" instead of 0). As soon as I rotate NumberPicker from now on, everything works.
How can I force NumberPicker to be formatted - both during the first rendering and when manually entering a number from the keyboard?
This is my formatter
public class PickerFormatter implements Formatter { private String mSingle; private String mMultiple; public PickerFormatter(String single, String multiple) { mSingle = single; mMultiple = multiple; } @Override public String format(int num) { if (num == 0) { return "-"; } if (num == 1) { return num + " " + mSingle; } return num + " " + mMultiple; } }
I add my formatter to the collector using setFormatter() , that's all I do for the collector.
picker.setMaxValue(max); picker.setMinValue(min); picker.setFormatter(new PickerFormatter(single, multiple)); picker.setWrapSelectorWheel(wrap);
android numberpicker formatter android-number-picker
A. Steenbergen Jul 17 '13 at 19:15 2013-07-17 19:15
source share