Dondani Dondani - 6 months ago 35
Android Question

How do I set a behaviour when a number picker reaches its min/max?

I'm making a custom NumberPicker to allow the user to select a real number with one decimal. This is what I did: I put two NumberPicker together and I set the min/max values at 0-9 and set setWrapSelectorWheel to false in the second one.

What I'd like to do to is increase/dicrease the first one when the second reaches a min/max. Can I implement some listener to achieve this?

I guess I could use setDisplayedValues with something like the next line, but it looks really cheap (I don't need an infinite range of numbers):

String[] numbers = {"0.0" , "0.1" ...};

Answer Source

You can set a listener on the second with setOnValueChangedListener and override onValueChange to check if you reached a min/max to increase/decrease the first numberPicker value.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download