I've a TimePicker on Android with two wheels. In the first I've hours in format 0 - 24, in the last I've minutes in interval step (generally 0 - 30).
When I change hour all work fine, when I set new value in minute timePicker change also the hours. there is a way in order to prevent it?
Here my code where I set values for the wheels:
Class<?> classForid = Class.forName("com.android.internal.R$id");
//picker ore
Field fieldHour = classForid.getField("hour");
hourPicker = (NumberPicker) timePicker.findViewById(fieldHour.getInt(null));
hourPicker.setMinValue(startHour);
hourPicker.setMaxValue(endHour);
//picker minuti
Field fieldMinute = classForid.getField("minute");
minutePicker = (NumberPicker) timePicker.findViewById(fieldMinute.getInt(null));
minutePicker.setMinValue(0);
minutePicker.setMaxValue(numberFractionHour - 1);
float pickerInterval = 60 / numberFractionHour;
displayedMinutesValues = new ArrayList<String>();
for (int i = 0; i < 60; i += pickerInterval)
displayedMinutesValues.add(String.format("%02d", i));
minutePicker.setDisplayedValues(displayedMinutesValues.toArray(new String[0]));
Thanks in advance.
Use code below to prevent hourPicker getting updated.
minutePicker.setOnValueChangedListener(null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With