Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 8th, 2012  |  syntax: None  |  size: 0.52 KB  |  hits: 5  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Android to detect when you are holding down a button
  2. if ButtonIsBeingPressed
  3. {
  4. chronometer start(); //and keep going
  5. }
  6. else chronometer stop();
  7. //or on release or something
  8. }
  9.        
  10. view.setOnTouchListener(new OnTouchListener() {
  11.     @Override
  12.     public boolean onTouch(View v, MotionEvent event) {
  13.         switch(event.getAction()) {
  14.         case MotionEvent.ACTION_DOWN:
  15.             // Start
  16.             break;
  17.         case MotionEvent.ACTION_UP:
  18.             // End
  19.             break;
  20.         }
  21.         return false;
  22.     }
  23. });