Android Progressbar not updating

前端 未结 5 1414
情深已故
情深已故 2021-01-28 22:33

i got a problem in updating progress bar. I am updating progress bar in separate Thread and the variable on which the progressbar progress is depending(which is a class variable

5条回答
  •  臣服心动
    2021-01-28 23:15

    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.

提交回复
热议问题