开发者

How To Check View Contains Another View?

开发者 https://www.devze.com 2023-04-04 00:30 出处:网络
Is there 开发者_运维百科a way to check if a view contains another certain view? (indexOfChild only works with one level of hierarchy)If child doesn\'t have an id, try something like this:

Is there 开发者_运维百科a way to check if a view contains another certain view? (indexOfChild only works with one level of hierarchy)


If child doesn't have an id, try something like this:

child.getParent() == parent


You can use findViewById() to find the view. like:

yourview.findViewById(R.id.childView);


I guess you want to check if a View is present inside a ViewGroup? The easiest way I can think of is to use .findViewById() on the ViewGroup, and assign an ID for the View that you're looking for.

0

精彩评论

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