Android SeekBar set progress value

后端 未结 6 975
旧时难觅i
旧时难觅i 2020-12-06 16:22

I want the SeekBar progress to change whenever I click a button. Using setProgress() works only for initial value. It throws an error if I use it

6条回答
  •  既然无缘
    2020-12-06 16:50

    Try this :

    seekBar.setMax(50);
    seekBar.setProgress(22);
    

    instead of :

    seekBar.setProgress(22); seekBar.setMax(50);

    Only if you set the Max Value first, can the SeekBar get an idea of how much progress is actually made, when you set the progressValue.

    This actually made a difference for me when I wanted a default value for my Progress Bar

提交回复
热议问题