Search code examples
androiduser-interfaceseekbar

Android seekbar how to block dragging / disable it for short time


I want to block the dragging of a seekbar if a value is true. Is this even possible? I use a seekbar as a switch. If my seekbar value is 0, and I press the button action A started. If my seekbar value is 1 and I press the button action B is started.
I want to prevent that If action A or B is running the seekbar is dragged to another position.

How can I achieve this?


Solution

  • You should set your own onTouchListener and just return true.

    seekBar.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View view, MotionEvent motionEvent) {
                    return true;
                }
            });