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

后端 未结 2 1329
时光说笑
时光说笑 2021-01-06 02:34

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

相关标签:
2条回答
  • 2021-01-06 03:04
    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 讨论(0)
  • 2021-01-06 03:05

    Try this..it works fine..

    mSeekBar.setEnabled(false);
    
    0 讨论(0)
提交回复
热议问题