How do I perform something while the something is long pressed and something when it is released? I am using Gesture Detector to handle events
Asked
Active
Viewed 303 times
0
-
see this http://stackoverflow.com/questions/7919865/detecting-a-long-press-with-android/11679788#11679788 – amrinder007 Jun 05 '13 at 08:41
1 Answers
0
The longpress is a specific action. For your purposes I think you will have to look at onTouchEvent(MotionEvent ev)
ACTION_DOWN is when a press has started.
ACTION_UP is when it is released.

Ken Wolf
- 23,133
- 6
- 63
- 84
-
-
put the "something1" you want to execute in ACTION_DOWN, put the other "something2" you want to execute in ACTION_UP. When user presses down, "something1" will fire. When they let go, "something2" will fire. Is this not what you want? If not please describe when you want things to happen. – Ken Wolf Jun 05 '13 at 12:30
-
In this case, 'something1' will fire immediately when the user touches the screen, I want it to fire up when he has long pressed the screen and keep going on till he releases the screen. As he releases, 'something2' should immediately fire. – dungeon_master Jun 06 '13 at 04:10
-
I'd find out how long a long-press is (`ViewConfiguration.getLongPressTimeout()` will tell you), on first ACTION_DOWN set up a handler/timer to fire "something1" after that period of time (cancel it if you get ACTION_UP before then, this indicates the user has not pressed as long as a long-press). First time you get ACTION_UP after that time, fire "something2". This will do what you describe above. – Ken Wolf Jun 06 '13 at 05:03