Android NumberPicker with Formatter doesn’t format on first rendering

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]);

How to create a number picker dialog?

I have made a small demo of NumberPicker. This may not be perfect but you can use and modify the same. public class MainActivity extends Activity implements NumberPicker.OnValueChangeListener { private static TextView tv; static Dialog d ; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tv = (TextView) findViewById(R.id.textView1); Button b = (Button) findViewById(R.id.button11); b.setOnClickListener(new … Read more

Change the text color of NumberPicker

The solution I tried and worked for me is: In styles.xml add: <style name=”AppTheme.Picker” parent=”Theme.AppCompat.Light.NoActionBar” > <item name=”android:textColorPrimary”>@android:color/black</item> </style> Then use it like this inside your layout: <NumberPicker android:id=”@+id/dialogPicker” android:theme=”@style/AppTheme.Picker” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_marginTop=”15dp” />