How to detect touch events in Android -


Is it possible to detect and capture all the touch events in an activity and then pass the event to the second Pass in the scene?

For example: <1 p>

Button 1 and button 2. When button 1 is pressed, I want to capture that touch / click event and automatically open that touch event At the button 2 I want to put a touch / press, you basically generate a click and the same click is automatically passed on to the other button.

Look at this API details first.


Boolean Android.AP Activity. Disruptive Touch Event (Motion Event Eve)

Public Boolean Dispatch Touch Event (Motion Even Eve) Since: API level 1 called to process touch screen events All touch screens before you are sent to the window You can override it to block events. Be sure to call this implementation for touch screen events, which should be handled as normal.

Parameters avi touch screen event.

Return boolean returns if this event is used.

As you can see, you can stop all touch events

@ Override Public Boolean Dispatch Touch Event ({ / Auto auto-generated method stub super display (EVE); If (BTN 1. Touch Event (EVU)) {Return BTN 2 Touch Event (Eve); } Other {return false; }}

These are the codes that you see I think.


Comments