The user of our app should be able to adjust a floating point number. At the moment, I filled an ArrayAdapter with all possible values and attached it to a spinner.
This solution doesn't really meet our expectations, since the spinner dropdown box is way too tall. Is there a better way? I was looking at Numberpicker - but this seems to work only with Integer values.
Any ideas?
Thanks!
NumberPicker
is not just for integers.. Even you can useFloats
String
etc.see this and read about it.
for tutorials :
And I had used
NumberPicker
long ago like this and it might be some use posting here:You can make
ArrayList
of any datatype and assign it.Another solution is to combine two numberfields into one component. See the Money Picker Example. Its advantage is that you don't have to initialize all possible double values for your spinner.
You may also need to attach special digits formatting, like "00", "0123" or other, using
java.lang.String.format()
function. Example is here.Add Double Picker xml-layout:
Add custom Double Picker class:
Use new Double Picker component in your activity xml: