Android numberpicker set value seen on open

Manish picture Manish · Nov 4, 2015 · Viewed 9.2k times · Source

I am looking to set the numberpicker a default value when I click on it. Now it shows "0". I want to pick the number you see as first in the numberpicker. I am working with integers.

It should be very easy, but I can't find it. This needs to be done programmatically.

Many thanks,

Answer

fractalwrench picture fractalwrench · Nov 4, 2015

You should call setValue() on the NumberPicker instance, if you wish to use a default value:

numberPicker.setValue(5); // example value