Android: SeekBar Increment Value - How To

headscratch picture headscratch · Aug 1, 2010 · Viewed 13.7k times · Source

My SeekBar (slider) works just fine but, it increments/decrements by one's as I slide my finger but, I want to change the increment value to a constant, such as 5. I tried using

slider.incrementProgressBy(5);

to do it but, it doesn't work (note: I placed it in different locations, inside and outside the action listener, but it didn't work).

Here are the two lines that relate to this:

slider.incrementProgressBy(5);
validBpm = slider.getProgress();

Those lines are currently inside the SeekBar's touch listener.

I imagine it's simple and I'm overlooking the obvious - any suggestions? Thanks...

Answer

CommonsWare picture CommonsWare · Aug 1, 2010

AFAIK, you cannot change the SeekBar increment value. Instead, change your max (setMax()) and use multiplication. For example, rather than 0 to 25 incrementing by 5, use 0 to 5 incrementing by one, then multiply the SeekBar value by 5 to get your result.