Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Seekbar - only allow change with thumb?

Tags:

android

I have a seekbar that I want to only allow changing with the thumb/handle portion. If the user taps anywhere else, I'd like that tap to be ignored.

Is there an inherant property to do this? If not, I already know I can set an onTouch listener and return true to "disable" it, but is there a way to detect when the thumb is tapped so that I can tell onTouch to return false in that case?

like image 228
bugfixr Avatar asked Jul 01 '11 15:07

bugfixr


1 Answers

I assume you want to change thumb position via code, which is user restricted.so for that try this.may be could help you.

            myseekBar.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);
                }               
            }
        });
like image 195
βhargavḯ Avatar answered Oct 27 '22 18:10

βhargavḯ