title: Android ExpandableLists, implementing Gestures, setting onTouch Listener makes expandable List dissapear
body: <p>the example below makes my Expandable List dissapear as soon as I set either the OnTouch listener or onCLick listener. </p>
  
  <p>I have a ActivityswipeDetector Class:</p>
  
  <pre><code>public class ActivitySwipeDetector implements View.OnTouchListener {
  
  public static enum Action {
      LR, // Left to Right
      RL, // Right to Left
      TB, // Top to bottom
      BT, // Bottom to Top
      None // when no action was detected
  }
  
  
  private static final String logTag = "SwipeDetector";
  private static final int MIN_DISTANCE = 100;
  private float downX, downY, upX, upY;
  private Action mSwipeDetected = Action.None;
  
  
  public boolean swipeDetected(){
      return mSwipeDetected != Action.None;
  }
  
  public Action getAction(){
      return mSwipeDetected;
  }
  
  
  public boolean onTouch(View v, MotionEvent event) {
      switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN: {
          downX = event.getX();
          downY = event.getY();
          mSwipeDetected = Action.None;
          return false; // allow other events like Click to be processed
      }
      case MotionEvent.ACTION_UP: {
          upX = event.getX();
          upY = event.getY();
  
          float deltaX = downX - upX;
          float deltaY = downY - upY;
  
          // horizontal swipe detection
                  if (Math.abs(deltaX) &gt; MIN_DISTANCE) {
                      // left or right
                      if (deltaX &lt; 0) {
                          Log.i(logTag, "Swipe Left to Right");
                          mSwipeDetected = Action.LR;
                          return false;
                      }
                      if (deltaX &gt; 0) {
                          Log.i(logTag, "Swipe Right to Left");
                          mSwipeDetected = Action.RL;
                          return false;
                      }
                  } else 
  
                  // vertical swipe detection
                  if (Math.abs(deltaY) &gt; MIN_DISTANCE) {
                      // top or down
                      if (deltaY &lt; 0) {
                          Log.i(logTag, "Swipe Top to Bottom");
                          mSwipeDetected = Action.TB;
                          return false;
                      }
                      if (deltaY &gt; 0) {
                          Log.i(logTag, "Swipe Bottom to Top");
                          mSwipeDetected = Action.BT;
                          return false;
                      }
                  } 
                  return false;
      }
      }
      return false;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>And within my main class I add the following at the top of the onCreate method- but the first two lines make the Expandable list dissapear:</p>
  
  <pre><code>final ActivitySwipeDetector swipeDetector = new ActivitySwipeDetector();
           list.setOnTouchListener(swipeDetector);
  
           list.setOnItemClickListener(new OnItemClickListener() {
  
                  public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
                          if (swipeDetector.swipeDetected()){
                              // do the onSwipe action 
                          } else {
                              // do the onItemClick action
                          }
                      }
                                  });
              list.setOnItemLongClickListener(new OnItemLongClickListener() {
                  public boolean onItemLongClick(AdapterView&lt;?&gt; parent, View view,int position, long id) {
                      if (swipeDetector.swipeDetected()){
                          // do the onSwipe action
                          return true;
                      } else {
                          // do the onItemLongClick action
                          return false;
                      }
                  }
              });
  </code></pre>
  
  <p>the "list" is defined as list= getExpandableListView(); </p>
  
  <p>So 1) what am I doing wrong that makes the expandable list dissapear</p>
  
  <p>2) Should I be using onGroupClick listener and onChildClick listeners? If so please advise n where I add them</p>
  
  <p>3) Where it says "do the swipe action" and "do the OnItemClick action", what do I add?</p>
  
  <p>I am to use left-to-right swipes to expand on an item in the list</p>
  
  <p>right-to-left- swipes to go back, and I have a button that has code for that already so i should just replace that with the swipe I assume?</p>
  
  <p>Any Help would be greatly appreciated!</p>
  
  <p>Z </p>