Skip to content Skip to sidebar Skip to footer

Same Touch Listener Is Called Multiple Times

I have multiple ImageViews on my screen. Whenever the user moves his finger over one or multiple of them, I want the ones the finger touched, to be removed and create new ImageView

Solution 1:

It seems you are confused at the start line :)

Some explanation.

When Android catch TouchEvent, he dispatch him to root element, and root in his turn - dispatch to all childs recursively, thought view tree, until some view signalize that touch event is processed, and no one view can handle this event.

So.

If you need to dispatch TouchEvent from one View to Another you should jumping up to one level and dispatch from there.

Diagram

enter image description here

You should set setOnTouchListener to parent ViewGroup and throw forward to his children.

Post a Comment for "Same Touch Listener Is Called Multiple Times"