Search code examples
androideventsonclickroutesevent-bubbling

Android route / bubble events because a control is consuming the onClick event


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?


Solution

  • Have you set the onClickListener in your custom view?

    Set your custom view as clickable.

    I don't recommend on setting any click listener in the child views.

    Does it work now?