问题
I've been reading through the docs, and I cannot figure out how to cancel a "drag" on a Seekbar once the bar has been completed.
For example, when I drag the bar to the end, I want an event to happen. However, if I keep my finger on the screen and drag my finger past the SeekBar, it keeps firing off that event even after I reset the progress of the Seekbar. How can I prevent this action from happening?
Thanks
回答1:
Try this..it works fine..
mSeekBar.setEnabled(false);
回答2:
seekBarObj.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
int originalProgress;
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
originalProgress = seekBar.getProgress();
}
@Override
public void onProgressChanged(SeekBar seekBar, int arg1, boolean fromUser) {
if(fromUser == true){
seekBar.setProgress(originalProgress);
}
}
});
来源:https://stackoverflow.com/questions/2917969/how-do-i-cancel-a-drag-motion-on-an-android-seekbar