title: Custom PagerTabStrip how to disable switching tabs via click - Not Working
body: <p>I want to disable the "switching tabs by clicking on tab name" of the PagerTabStrip based on a condition.</p>
  
  <p>I think the following code is right but I am still able to switch tabs by clicking on the tab names. I was able to disable the switching of tabs via swipe by custom ViewPager but I want to disable by clicking on tab names too.</p>
  
  <p>My custom PagerTabStrip</p>
  
  <pre><code>package com.blah;
  
  import android.content.Context;
  import android.support.v4.view.PagerTabStrip;
  import android.util.AttributeSet;
  import android.view.MotionEvent;
  
  public class CustomPagerTabStrip extends PagerTabStrip {
  
      private boolean isTabSwitchEnabled;
  
      public CustomPagerTabStrip(Context context, AttributeSet attrs) {
          super(context, attrs);
          this.isTabSwitchEnabled = true;
      }
  
      @Override
      public boolean onInterceptTouchEvent(MotionEvent event) {
          System.out.println("ENable?? "+isTabSwitchEnabled); // it prints out false or true based on what I have set
          if (this.isTabSwitchEnabled) {
              return super.onInterceptTouchEvent(event);
          } else {
              return false;
          }
      }
  
      @Override
      public boolean onTouchEvent(MotionEvent event) {
          if (this.isTabSwitchEnabled) {
              return super.onTouchEvent(event);
          }
          return false;
      }
  
      public void setTabSwitchEnabled(boolean isSwipeEnabled) {
          this.isTabSwitchEnabled = isSwipeEnabled;
      }
  }
  </code></pre>
  
  <p>I disable it by using:</p>
  
  <pre><code>CustomPagerTabStrip pagerTabStrip = (CustomPagerTabStrip) findViewById(R.id.tabtitle);
  pagerTabStrip.setTabSwitchEnabled(false);
  </code></pre>
  
  <p>My layout:</p>
  
  <pre><code>&lt;com.blah.CustomViewPager xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/pager"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
          &lt;com.blah.CustomPagerTabStrip
              android:id="@+id/tabtitle"
              style="@style/viepagertitlestrip"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_gravity="top"
              android:background="@color/primary"
              android:paddingBottom="4dp"
              android:paddingTop="4dp"
              &gt;
  
          &lt;/com.blah.CustomPagerTabStrip&gt;
      &lt;/com.blah.CustomViewPager&gt;
  </code></pre>