Android NumberPicker with Formatter doesn't format on first rendering

前端 未结 9 1824

I have a NumberPicker that has a formatter that formats the displayed numbers either when the NumberPicker spins or when a value is entered manually. This works fine, but wh

9条回答
  •  渐次进展
    2020-12-01 09:39

    dgel's solution doesn't work for me: when I tap on the picker, formatting disappears again. This bug is caused by input filter set on EditText inside NumberPicker when setDisplayValues isn't used. So I came up with this workaround:

    Field f = NumberPicker.class.getDeclaredField("mInputText");
    f.setAccessible(true);
    EditText inputText = (EditText)f.get(mPicker);
    inputText.setFilters(new InputFilter[0]);
    

提交回复
热议问题