views:

80

answers:

1

is there a way to get every view that is inside my activity? I have over 200 views including buttons, and images, so i want to be able to access them by using a loop

for example something like

for (View v : this)
{
     //do something with the views 
     //depending on the types (button, image , etc)
}
+2  A: 

is there a way to get every view that is inside my activity?

Get your root View, cast it to a ViewGroup, call getChildCount() and getChildAt(), and recurse as needed.

I have over 200 views including buttons, and images, so i want to be able to access them by using a loop

That is a rather large number of Views.

CommonsWare
thanks a lot , perfectan invisible object (button) was blocking my whole screen, I used this to find out what item was blocking and found it :)
aryaxt
The `hierarchyviewer` tool that comes with the SDK can help you find issues like this. It can display your app's view hierarchy visually as a tree, allowing you to inspect the properties of each view.
adamp
I know but most of the objects are added to the screen through code.
aryaxt