tags:

views:

143

answers:

1

New to android so please bare with me here :-)

Is it possible to detect all touch events in an Activity and capture it and then in return pass that pass event to another View. For example:

Button 1 and Button 2. When Button 1 is pressed I want to capture that touch/click event and automatically pass that touch event to Button 2, basically with one touch/press you get the click generated and that same click is passed on to the second button automatically.

Thank You!

A: 

I imagine that you could take the TouchEvent from the button press, and make a call to the other button, passing in the TouchEvent, but I am not sure how safe that would be. (Android may bomb on you)

A safer solution would be to subclass Button, and use the Observer design pattern. You could register each buttons to listen for button presses of each other button, and then you would be able to safely pass the TouchEvent's between all of them.

If you are unfamiliar with the Observer design pattern, here is a link: http://en.wikipedia.org/wiki/Observer_pattern

nicholas.hauschild