Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: SeekBar Increment Value - How To

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

like image 381
headscratch Avatar asked Aug 01 '10 15:08

headscratch


1 Answers

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.

like image 58
CommonsWare Avatar answered Sep 29 '22 20:09

CommonsWare