title: Android onTouch with onClick and onLongClick
body: <p>I've got a custom view which acts like a button. I want to change the background when user press it, revert the background to original when user moves the finger outside or release it and I also want to handle onClick/onLongClick events. The problem is that onTouch requires me to return true for <code>ACTION_DOWN</code> or it won't send me the <code>ACTION_UP</code> event. But if I return true the <code>onClick</code> listener won't work.</p>
  
  <p>I thought I solved it by returning false in onTouch and registering onClick - it somehow worked, but was kinda against the docs. I've just received a message from an user telling me that he's not able to long-click on the button, so I'm wondering what's wrong here.</p>
  
  <p>Part of the current code:</p>
  
  <pre><code>public boolean onTouch(View v, MotionEvent evt)
  {
    switch (evt.getAction())
    {
      case MotionEvent.ACTION_DOWN:
      {
        setSelection(true); // it just change the background
        break;
      }
  
      case MotionEvent.ACTION_CANCEL:
      case MotionEvent.ACTION_UP:
      case MotionEvent.ACTION_OUTSIDE:
      {
        setSelection(false); // it just change the background
        break;
      }
    }
  
    return false;
  }
  
  public void onClick(View v)
  {
    // some other code here
  }
  
  public boolean onLongClick(View view)
    {
      // just showing a Toast here
      return false;
    }
  
  
  // somewhere else in code
  setOnTouchListener(this);
  setOnClickListener(this);
  setOnLongClickListener(this);
  </code></pre>
  
  <p>How do I make them work together correctly?</p>
  
  <p>Thanks in advance</p>