How to update SeekBar without activating OnSeekBarChangeListener?

I have a SeekBar with an OnSeekBarChangeListener app application. Each time a user changes a value, his onProgressChanged () method is launched. It's fine.

But then I try to update the SeekBar move as follows:

seekBar.setProgress(value);

I expect that no events will happen - just the progress of SeekBar will change. But onProgressChanged () is also called in this case.

How can I change the course of SeekBar without triggering events?

+4
source share
2 answers
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {}

Look at the options. You have a boolean fromUser, use it.

if (fromUser) {
.........
.........
}

, . , , - if(). . -Marco -

+13

SeekBar. , onProgressChanged.

,

seekBar.setOnSeekBarChangeListener(null);
seekBar.setProgress(value);
seekBar.setOnSeekBarChangeListener(this);
0

All Articles