Is there a way to use the Android NumberPicker widget for choosing strings instead of integers?
Unfortunately, you can't style it. The styles and styling attributes for NumberPicker are not present in the public API, therefore you can't set them and change the default look. You can only select between light and dark theme. As a solution I would suggest to use android-numberpicker library instead.
Implementing Horizontal picker in Android using RecyclerView and LinearLayoutManager with kotlin. Its a number picker which has the below functionality. >middle item will be selected, clicking on item will also be selected.
NumberPicker picker = new NumberPicker(this); picker.setMinValue(0); picker.setMaxValue(2); picker.setDisplayedValues( new String[] { "Belgium", "France", "United Kingdom" } );
NumberPicker numberPicker = new NumberPicker(this); String[] arrayString= new String[]{"hakuna","matata","timon","and","pumba"}; numberPicker.setMinValue(0); numberPicker.setMaxValue(arrayString.length-1); numberPicker.setFormatter(new NumberPicker.Formatter() { @Override public String format(int value) { // TODO Auto-generated method stub return arrayString[value]; } });
hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With