How can we limit seekbar to make progress in fixed steps [duplicate]
-
13-12-2019 - |
Pregunta
Possible Duplicate:
Android: Set interval in SeekBar
I have a seekbar with max value as 100 So the total span of values it can take is 0-100.
but my requirement is that the progress shown on seekbar should only be in fixed steps. i.e. I only want my seekbar to take these values 1, 10 , 20, 30, 40, ....90, 100 and not any value between these steps.
how can I limit my seekbar to work in this manner?
Please help
Solución
store the possible values in an array and use the current seek-bar value as the array-index.
Pseudo-code
int[] values = {1, 10 , 20, 30, 40, ....90, 100};
int current = values[ seekbar.getValue() ];
So for if seekbar.getValue() == 1 your current == 10.
Otros consejos
You can make your seekbar's max as 10 and while displaying the selected value, get the current progress and multiply with 10.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow