开发者

How To Check View Contains Another View?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜