开发者

How do I cancel a "drag" motion on an Android Seekbar?

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 wan开发者_运维百科t 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


Try this..it works fine..

mSeekBar.setEnabled(false);


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);
            }               
        }
    });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜