title: ViewPager Swipe with Button OnTouchListener event
body: <p>I have a <code>ViewPager</code> with 2 items into it and a <code>Button</code> for <code>ViewPager Animation</code> . I wanted to swipe the <code>ViewPager</code> with the TouchEvent of Button without moving my finger up i.e Sliding my finger from Button &amp; getting the ViewPager Swipe</p>
  
  <p>Currently I am able to get A swipe only when I move Up my finger &amp; swipe  not on the <code>TouchEvent</code></p>
  
  <p>Below is My code Snippets...of XML</p>
  
  <p></p>
  
  <pre><code>&lt;Button
      android:id="@+id/slide_btn_speak"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_alignParentLeft="true"
      android:background="@android:drawable/ic_btn_speak_now"
      android:contentDescription="@string/app_name" /&gt;
  
  &lt;TextView
      android:id="@+id/slide_txtView_inside"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerVertical="true"
      android:layout_marginLeft="20dp"
      android:layout_toRightOf="@+id/slide_btn_speak"
      android:text="@string/app_name" /&gt;
  
  &lt;android.support.v4.view.ViewPager
      android:id="@+id/ui_pager"
      android:layout_width="wrap_content"
      android:layout_height="150dp"
      android:layout_alignParentBottom="true"
      android:layout_alignParentRight="true"
      android:layout_alignTop="@+id/slide_btn_speak"
      android:layout_toRightOf="@+id/slide_btn_speak"
      android:scrollbars="horizontal" &gt;
  
  &lt;/android.support.v4.view.ViewPager&gt;
  
  &lt;Button
      android:id="@+id/slide_btn_drag"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_alignParentRight="true"
      android:background="@android:drawable/ic_btn_speak_now"
      android:contentDescription="@string/app_name" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>My Activity Snippets...</p>
  
  <pre><code>public class SlidingActitvity extends Activity {
  
      ViewPager viewPager;
  
      Button slide_button_start ; 
  
      Vibrator vibrator;
  
      static int count ;
  
      int x_position, y_position;
  
      String hint[] ={" SWIPE TO CANCEL " , ""};
      @Override
  
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.activity_sliding_actitvity);
  
          viewPager = (ViewPager) findViewById(R.id.ui_pager);
  
          vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
  
          slide_button_start = (Button) findViewById(R.id.slide_btn_drag);
  
  
  
          slide_button_start.setOnTouchListener(new OnTouchListener() {
  
              @Override
              public boolean onTouch(View v, MotionEvent event) {
  
  
                  switch (event.getAction()) {
  
                  case MotionEvent.ACTION_MOVE:
  
                      int viewPager_width = viewPager.getWidth();
  
                      x_position = (int) event.getX();
                      y_position = (int) event.getY();
                      if(x_position&lt;= 0){
  
                          vibrator.cancel();
                          viewPager.bringToFront();
  
                          logIt("Touch..." +x_position +"..."+y_position);
                      }
  
                      break;
  
                  case MotionEvent.ACTION_DOWN:
  
                      vibrator.vibrate(100);
  
                      final Animation animation = AnimationUtils.loadAnimation(SlidingActitvity.this, R.anim.left);
  
                      ViewPagerAdapter adapter = new ViewPagerAdapter(SlidingActitvity.this , hint);
  
                      viewPager.setAdapter(adapter);
  
                      viewPager.setVisibility(ViewPager.VISIBLE);
  
                      viewPager.setAnimation(animation);
  
  
                      logIt("Touch...Down");
  
                      break;
  
                  case MotionEvent.ACTION_UP:
  
                       logIt("Touch...Up");
                       vibrator.cancel();
  
                       break;
                  case MotionEvent.ACTION_OUTSIDE:
                      logIt("Your are out...");
                      vibrator.cancel();
                  break ;
                  default:
                      break;
                  }
  
                  return true;
              }
          });
  
      }
  </code></pre>
  
  <p>Any Answer is Appreciated...</p>