androidandroid-layoutandroid-number-picker

Highlight selected item from number picker when it will open second time


I have number picker and I am filling it with string array.

final String[] power = {"0.00", "0.25", "0.50", "0.75","1.00"};
npPowerSecond.setMinValue(0);
npPowerSecond.setMaxValue(power.length - 1);
npPowerSecond.setDisplayedValues(power);

I display values as above. When I open number picker it will show "0.00" as a selected value. Now I am selecting "0.50". Now When I will open number picker, it should display "0.50" as selected value.

Can you please help me? How can I achieve this?


Solution

  • npPowerSecond.setValue(2);
    

    use setvalue to set.