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

Leandros picture Leandros · Jan 15, 2012 · Viewed 30.6k times · Source

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?

Answer

Maxim Tulupov picture Maxim Tulupov · Apr 26, 2013

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