views:

94

answers:

1

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

A: 

Hey, try this;

seekBarObj.setOnSeekBarChangeListener( new OnSeekBarChangeListener() {

        int originalProgress;

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

        }

        @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);
            }               
        }
    });
jaxvy