title: Detecting swipes, click, hold on one View Android
body: <p>I have an <code>ImageView</code> which fills my whole <code>Activity</code>. I need to be able to detect 4 touch events : </p>
  
  <ul>
  <li>Hold (longer than 400 ms)</li>
  <li>Click</li>
  <li>Swipe Left</li>
  <li>Swipe Right</li>
  </ul>
  
  <p>At the moment I am able to detect the first two using the following code :</p>
  
  <pre><code>imageView.setOnTouchListener(new View.OnTouchListener() {
  
      private Timer timerr = new Timer();
      private long LONG_PRESS_TIMEOUT = 400; // TODO: your timeout here
      private boolean wasLong = false;
  
      @Override
      public boolean onTouch(View v, MotionEvent event) {
        Log.d(getClass().getName(), "touch event: " + event.toString());
  
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
         // HOLD DETECTED
         timerr.schedule(new TimerTask() {
            @Override
            public void run() {
              SlideShow.this.runOnUiThread(new Runnable() {
                @Override
                public void run() {
  
                }, LONG_PRESS_TIMEOUT);
               return true;
              }
  
              if (event.getAction() == MotionEvent.ACTION_UP) {
               if (!isPaused &amp;&amp; !wasLong) {
                // CLICK DETECTED
                timerr.cancel();
                timerr = new Timer();
                if (!wasLong) {
  
                 return false;
                }
               });
  </code></pre>
  
  <p>Now I am trying to use the code from this question to implement the swipe right and swipe left actions. <a href="https://stackoverflow.com/questions/4373485/android-swipe-on-list">Android Swipe on List</a> The problem with this is that this works on  listview, where you can implement an <code>onTouchListener</code> for the whole listview, and a seperate <code>onItemClickListener</code> for the list item. I do not know how to adapt this to this situation though where only one Listener is available.</p>