I am using a Seekbar
in a fragment and need to move the Seekbar
to different positions. However, setProgress(xxx)
is not working.
How do you trigger this method programmatically for a Seekbar
: public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
? Moving the Seekbar
manually works fine.
It's a Bug in ProgressBar!
The setProgress(...)
seems to not trigger the update on the drawable
if the same value is passed again. But it's not triggered during the setMax, too. So the update is missing.
To solve this, I'm just doing a bar.setProgress(0)
before each update... this is only a workaround, but it works for me as expected:
bar.setProgress(0); // call these two methods before setting progress.
bar.setMax(20);
bar.setProgress(20);
Second Option.
mSeekBar.post(new Runnable() {
@Override
public void run() {
mSeekBar.setProgress(percentOfFullVolume);
}
});
it may also work for someone.
Try to set max value first and then set the progress.