title: How to swipe list view item left in Android?
body: <p>I have a list view and I want to make it so I can swipe each item to reveal a delete button:</p>
  
  <p><a href="https://i.stack.imgur.com/Tey2b.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Tey2b.png" alt="enter image description here"></a></p>
  
  <p>I've figured out how to recognise the swipe event, I am using this code (<code>listItem</code> is of type <code>View</code>):</p>
  
  <pre><code>listItem.setOnTouchListener(new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) 
          {
              switch (event.getAction()) 
              {
                  case MotionEvent.ACTION_DOWN:
                      _xSwipe1 = event.getX();
                      break;
  
                  case MotionEvent.ACTION_UP:
                      _xSwipe2 = event.getX();
  
                      float deltaX = _xSwipe2 - _xSwipe1;
  
                      if (deltaX &lt; 0) 
                      {
                          Log.e("SWIPE", "Right to Left swipe");
                      }
  
                      else if (deltaX &gt;0)
                      {
                          Log.e("SWIPE", "Left to right swipe");
                      }
  
                      break;
              }
  
              return false;
          }
      });
  </code></pre>
  
  <p>And when I swipe, I can see in the logs that the swipe event is being recognised.</p>
  
  <p>However, I'm not sure how to physically make the list item start disappearing to the left?</p>
  
  <p>Any help would be greatly appreciated.</p>