Search code examples
androidseekbar

How can i get SeekBar value Like this?


i want to create seek bar in my project, for every step i want increment like this seek bar maxvalue = 6;

seek bar value increments : 0 1 2 3 4 5 6 
i want seek bar values like this : 0 2 5 10 15 20 25

how can i achieve this.


Solution

  • I would store the possible values in an array and use the current seek-bar value as the element-index for accessing the "desired" value.

    Pseudo-code

    int[] values = {0,2,5,10,15,20,25};
    int current = values[ seekbar.getValue() ];
    

    So for seekbar.getValue() == 2 your current == 5.