Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Check View Contains Another View?

Tags:

android

view

Is there a way to check if a view contains another certain view? (indexOfChild only works with one level of hierarchy)

like image 597
Arutha Avatar asked Sep 12 '11 08:09

Arutha


2 Answers

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

child.getParent() == parent
like image 195
Danylo.Vus Avatar answered Oct 04 '22 20:10

Danylo.Vus


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

yourview.findViewById(R.id.childView);
like image 36
Michele Avatar answered Oct 04 '22 21:10

Michele