开发者

Intercepting clicks from subview in Android

开发者 https://www.devze.com 2022-12-15 16:27 出处:网络
My application has a custom view which contains other custom views of a different type. The subviews have their own click listeners (which I can\'t change, as the开发者_开发百科se are in 3rd party lib

My application has a custom view which contains other custom views of a different type. The subviews have their own click listeners (which I can't change, as the开发者_开发百科se are in 3rd party libraries). How can I intercept a user's click at the level of my view to do some processing, and then pass the click on to the proper subview?


Justin, you can play with dispatchTouchEvent() or onInterceptTouchEvent().


I'm not entirely sure about this, but in Java what I would do is define various subview objects in my main view and simply send those to the draw/paint function. That way I'd only have ONE click listener which would be in the view anyways.

Can you do something like that in Android?

0

精彩评论

暂无评论...
验证码 换一张
取 消