title: Unable to swipe the screens horizontally
body: <p>Helo Evryone!</p>
  
  <p>I am trying to add "swipe" functionality in my app but i am unable to do so. I have stories to swipe left to right and vice versa. I have written a sub class MYGestureListener which has the following implementation.</p>
  
  <pre><code> class MyGestureListener extends SimpleOnGestureListener {
  
      @Override
      public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
  
          Log.e("Now", "onFling");
  
          try {
              if (Math.abs(e1.getY() - e2.getY()) &gt; SWIPE_MAX_OFF_PATH)
                  return false;
  
              // right to left swipe
              if (e1.getX() - e2.getX() &gt; SWIPE_MIN_DISTANCE &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY) {
                  // checking if current index is the last index
                  if (ind == items.size() - 1 || ind &gt; items.size() - 1) {
                      Log.e("Last Index", "Can't move further anymore");
                      return false;
                  } else {
                      ind++;
                      loadAndShowNextActivity();
                  }
              }
              // left to right
              else if (e2.getX() - e1.getX() &gt; SWIPE_MIN_DISTANCE &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY) {
  
                  if (ind &lt;= 0) {
                      Log.d("First Index", "Can't move back anymore");
                      return false;
                  } else {
                      ind--;
                      loadAndShowNextActivity();
                  }
              }
          } catch (Exception e) {
              System.out.println("Exception occured while flinging");
              e.printStackTrace();
          }
  
          return false;
      }
  }
  </code></pre>
  
  <p>Then i have overriden onTouchEvent() Function in main class. which is implemented as follows:</p>
  
  <pre><code>  @Override
  
  public boolean onTouchEvent(MotionEvent event) {
  
      Log.e("Now","onTouchEvent");
      if (gestureDetector.onTouchEvent(event))
          return true;
      else
          return false;
  }
  </code></pre>
  
  <p>and then calling its instance in onCreate of the main class as follows:</p>
  
  <pre><code>  gestureDetector = new GestureDetector(new MyGestureListener());
      gestureListener = new View.OnTouchListener() {
          public boolean onTouch(View v, MotionEvent event) {
              if (gestureDetector.onTouchEvent(event)) {
                  return true;
              }
              return false;
          }
      };  
  </code></pre>
  
  <p>It's not working, please suggest and identify where am i going wrong. Thanks in Advance..:-)</p>