title: Event when finger leaves button
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4597513/onpress-onrelease-in-android">onPress/onRelease in Android</a>  </p>
  </blockquote>
  
  
  
  <p>When a user holds a button the button changes color, and when the user leaves the button, the button returns to it's normal state. </p>
  
  <p>Is there an event that captures this ?</p>
  
  <p>I tried searching for something like button.onStateChanged, but no luck.. </p>
  
  <p>EDIT: 
  When the user long clicks I want to start the autoincrement</p>
  
  <pre><code>// Auto increment for a long click
          increment.setOnLongClickListener(new View.OnLongClickListener() {
              public boolean onLongClick(View a) {
                  autoIncrement = true;
  
                  repeatUpdateHandler.removeCallbacks(mRepeatUpdateHandler);
                  repeatUpdateHandler.post(mRepeatUpdateHandler);
  
                  return false;
              }
          });
  </code></pre>
  
  <p>And when the user leaves the button with his finger I want to stop the autoincrement </p>
  
  <pre><code>increment.setOnTouchListener(new View.OnTouchListener() {
          public boolean onTouch(View v, MotionEvent event) {
              if (event.getAction() == MotionEvent.ACTION_UP &amp;&amp; autoIncrement) {
  
                  //Stop autoincrement
  
                  repeatUpdateHandler.removeCallbacks(mRepeatUpdateHandler);
                  autoIncrement = false;
              }
  
              return false;
          }
      });
  </code></pre>
  
  <p>This is the handler: </p>
  
  <pre><code>RepetetiveUpdater mRepeatUpdateHandler = new RepetetiveUpdater();
   ....
  
  class RepetetiveUpdater implements Runnable {
      public void run() {
          if (autoIncrement) {
              increment();
              repeatUpdateHandler.postDelayed(new RepetetiveUpdater(),
                      REPEAT_DELAY);
          } else if (autoDecrement) {
              decrement();
              repeatUpdateHandler.postDelayed(new RepetetiveUpdater(),
                      REPEAT_DELAY);
          }
      }
  }
  </code></pre>
  
  <p>But this only works when the user lifts his finger above the button, when he drags it to somewhere else on the screen, the counter keeps running, any ideas? </p>