user940016 user940016 - 1 year ago 212
Android Question

Change the step size of a NumberPicker

Is it possible to do that in a more convenient way than handling it in the OnScrollListener event? Pity it doesn't have a step size attribute...

Answer Source

Why not just add an OnValueChangeListener Something like:

numberPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {

     public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
         picker.setValue((newVal < oldVal)?oldVal-5:oldVal+5);

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