I have a custom view with an ImageView and a TextView on it and implemented the onClickListener for my custom view. The problem is, that the ImageView is consuming the onClick-event (I just want the user be able to click on my control, no matter where). I could listen to the onClick of the Image/TextView too, but it seems dirty to me.
Is there a way to bubble / route Events in Android? Or possible another good solution?
View.onClick()
event does not bubble. Two possible solutions:
Register OnCLickListener
on you child views and then pass on the event by calling performClick()
on parent.
Use OnTouchListener
which bubbles up: just return false
in child view's onTouch()
method. This is more work as you have to account for touch-down & lift-up in order to emulate click.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With