Search code examples
androidprogressseekbarandroid-progressbar

How can we limit seekbar to make progress in fixed steps


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


Solution

  • 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.