PagerSlidingTabStrip icon indicating copy to clipboard operation
PagerSlidingTabStrip copied to clipboard

How can I disable the tabs?

Open coyarzun89 opened this issue 10 years ago • 4 comments

I was trying to disable the tabs, using the setEnable(false), but it doesn't work. Is there a way to disable the tabs? I'm doing an animation and I need to disable the tabs while the animation is been executed. After that, I have to enable the tabs again.

coyarzun89 avatar May 13 '14 08:05 coyarzun89

You have to modify the PagerSlidingTabStrip class.

whowazit avatar Jul 25 '14 02:07 whowazit

An alternative solution would be to extend the PagerSlidingTabStrip class and override the onInterceptTouchEvent() method to return true in case a flag is set, something like this:

public class CustomTabStrip extends PagerSlidingTabStrip {
    private boolean disabled;

    public CustomTabStrip(Context context) {
        super(context);
    }

    public CustomTabStrip(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomTabStrip(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        return disabled || super.onInterceptTouchEvent(ev);
    }
}

tomxor avatar Aug 20 '14 21:08 tomxor

Thank you

On Thu, Aug 21, 2014 at 5:46 AM, Tom Reznik [email protected] wrote:

An alternative solution would be to extend the PagerSlidingTabStrip class and override the onInterceptTouchEvent() method to return true in case a flag is set, something like this:

public class CustomTabStrip extends PagerSlidingTabStrip { private boolean disabled;

public CustomTabStrip(Context context) {
    super(context);
}

public CustomTabStrip(Context context, AttributeSet attrs) {
    super(context, attrs);
}

public CustomTabStrip(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
}

public void setDisabled(boolean disabled) {
    this.disabled = disabled;
}

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    return disabled || super.onInterceptTouchEvent(ev);
}}

— Reply to this email directly or view it on GitHub https://github.com/astuetz/PagerSlidingTabStrip/issues/94#issuecomment-52849299 .

whowazit avatar Aug 21 '14 06:08 whowazit

It works for me

geniushkg avatar Jul 21 '17 06:07 geniushkg