title: I am trying to implement a View Pager with controlled swiping.But I am getting a binary inflate exception on the custom view page
body: <p>I am trying to disable or enable the Viewpager's from swiping with a custom      Viewpager..But i am getting the inflating exception on the viewpager .Please anyone help me.</p>
  
  <h1>MainActivity</h1>
  
  <pre><code>public class MainActivity extends FragmentActivity {
  Timer timer;
  int page = 0;
  ViewPager pager;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);     
      pager = (ViewPager) findViewById(R.id.view_pager);
      pager.setAdapter(new MyPagerAdapter(getSupportFragmentManager()));
  
  
      pager.setEnabled(false);
  
  
      //pageSwitcher(3);
  
  
  
  
  }
  </code></pre>
  
  <p>////extending ViewPager class</p>
  
  <pre><code>public class HackyViewPager extends ViewPager {
      private boolean enabled;
      public HackyViewPager(Context context) {
          super(context);
      }
  
  
  
  
      public HackyViewPager(Context context, AttributeSet attrs) {
          super(context, attrs);
          this.enabled = true;
      }
  
  
      @Override
      public boolean onTouchEvent(MotionEvent event) {
          if (this.enabled) {
              return super.onTouchEvent(event);
          }
  
          return false;
      }
  
      @Override
      public boolean onInterceptTouchEvent(MotionEvent event) {
          if (this.enabled) {
              return super.onInterceptTouchEvent(event);
          }
  
          return false;
      }
  
      public void setPagingEnabled(boolean enabled) {
          this.enabled = enabled;
      } }
  </code></pre>
  
  <h1>activity_main Xml</h1>
  
  <h2>adding a custom viewpager</h2>
  
  <pre><code>     &lt;com.example.qms.MainActivity.HackyViewPager
       android:id="@+id/view_pager"
        android:layout_width="match_parent"
         android:layout_height="0dp"
         android:layout_weight="2.5" /&gt;
  
  
     # Exception #
  
   android.view.InflateException: Binary XML file line #32: Error inflating      
   class com.example.qms.MainActivity.HackyViewPager                  
  </code></pre>