How to make NumberPicker non-recurring

Simon Flückiger picture Simon Flückiger · Nov 25, 2012 · Viewed 11.9k times · Source

Is there any attribute to tell a (standard) NumberPicker to stop after its last value? E.g. if my MinValue was 0 and my MaxValue was 5 the NumberPicker just repeats itself after the 5, so that the user could scroll endlessly.

Answer

Opiatefuchs picture Opiatefuchs · Nov 25, 2012

If You had set min/max value, try this:

yourNumberPicker.setWrapSelectorWheel(false);

does this work for you?

EDIT

For TimePicker:

timePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
   public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
     if(hourOfDay>max) {
       TimePicker.setHour(max):
     }
     updateDisplay(hourOfDay, minute);
   }
});

It's not a tested code, but this could be the way you could do this.