private void initView() {
        setMinValue(MIN_VALUE);
        setMaxValue(MAX_VALUE);
        setValue(DEFAULT_VALUE);
        setBackgroundColor(BACKGROUND_COLOR);
        setSeparatorColor(SEPARATOR_COLOR);
        setTextColor(TEXT_COLOR);
        setTextSize(TEXT_SIZE);
        setWrapSelectorWheel(false);
        setFocusability(false);

        try {
            Field f = NumberPicker.class.getDeclaredField("mInputText");
            f.setAccessible(true);
            EditText inputText = (EditText)f.get(this);
            inputText.setFilters(new InputFilter[0]);
        } catch (NoSuchFieldException | IllegalAccessException | IllegalArgumentException e) {
            e.printStackTrace();
        }
    }
private void initView ( ) { setMinValue ( MIN_VALUE ) ; setMaxValue ( MAX_VALUE ) ; setValue ( DEFAULT_VALUE ) ; setBackgroundColor ( BACKGROUND_COLOR ) ; setSeparatorColor ( SEPARATOR_COLOR ) ; setTextColor ( TEXT_COLOR ) ; setTextSize ( TEXT_SIZE ) ; setWrapSelectorWheel ( false ) ; setFocusability ( false ) ; try { Field f = NumberPicker . class . getDeclaredField ( "mInputText" ) ; f . setAccessible ( true ) ; EditText inputText = ( EditText ) f . get ( this ) ; inputText . setFilters ( new InputFilter [ 0 ] ) ; } catch ( NoSuchFieldException | IllegalAccessException | IllegalArgumentException e ) { e . printStackTrace ( ) ; } }
Init number picker by disabling focusability of edit text embedded inside the number picker
We also override the edit text filter private attribute by using reflection as the formatter is still buggy while attempting to display the default value
This is still an open Google @see <a href="https://code.google.com/p/android/issues/detail?id=35482#c9">issue</a> from 2012