Seekbar OnProgressChanged doesn't get fired when moving manually

荒凉一梦 提交于 2019-12-22 13:54:02

问题


I have an app that is supposed to do some stuff when the seekbar is moved (manually). However, onProgressChanged never gets executed, even though I made sure that the progress value does change when moving the bar.

onStartTrackingTouch and onStopTrackingTouch both get fired without any problems.

public class MainActivity extends ActionBarActivity implements OnSeekBarChangeListener{

...

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    SeekBar seekBar = (SeekBar) findViewById(R.id.seekBar1);

    seekBar.setOnSeekBarChangeListener(this);


}

@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
...



}

回答1:


I have similar problem, onProgressChanged() not fired, but onStartTrackingTouch() and onStopTrackingTouch() no such problem.

In my case, user not able to drag seekbar after re-enter the activity page, it happen randomly.

It's because of mediaControl.seek() code inside onProgressChanged() stuck. The way I fixed it is to ensure mediaControl object assigned is the latest one with valid duration (i.e. mediaControl.getDuration()'s onSucces() != 0L).

So if you have similar problem, please first check your object inside onProgressChanged(), it probably something wrong with that object.



来源:https://stackoverflow.com/questions/29200087/seekbar-onprogresschanged-doesnt-get-fired-when-moving-manually

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!