问题
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