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.
精彩评论