0

I want to keep a button pressed and WHILE pressed it will do something. I firstly confused it with onLongClick() but this method will perform an action after long pressed. Tried everything but it doesn't work. Does anyone has an idea how can I achieve this?

Davin Tryon
  • 66,517
  • 15
  • 143
  • 132

1 Answers1

4

You are probably looking for something more along the lines of the View.OnTouchListener

Set the listener on your button and listen for the MotionEvent.ActionDown event found here

kick off your code when you receive ACTION_DOWN, and stop it when your receive ACTION_UP.

Nick H
  • 8,897
  • 9
  • 41
  • 64
  • This is my actual problem to be precise: http://stackoverflow.com/questions/34830916/send-data-to-arduino-as-long-as-the-button-is-being-pressed – user3882221 Jan 16 '16 at 19:08