Android NumberPicker with Formatter doesn't format on first rendering

前端 未结 9 1843

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:51

    Calling the private method changeValueByOne() via reflection as described in an earlier answer works for me on API Level 16 (Android 4.1.2 and up), but it does not seem to help on API Level 15 (Android 4.0.3), however!

    What works for me on API Level 15 (and up) is to use your own custom formatter to create String array and pass that with the method setDisplayedValues() to the number picker.

    See also: Android 3.x and 4.x NumberPicker Example

提交回复
热议问题