Is there any way in Android
by which we get something like Map and List or any other collection object that give us object of all the fields (like Text-view, Edit-text, Button and any other widgets) that has been used or initialized in an Activity
?
Asked
Active
Viewed 39 times
0
1 Answers
3
What you'd have to do is get a hold of your root view in your xml using getViewById()
, and next recursively get its children using getChildCount()
and getChildAt()
until you have them all.
Note that the getChildCount
method only applies to ViewGroups
(these are things like LinearLayout
, RelativeLayout
,...).
Look here for a possible duplate.

Community
- 1
- 1

Toon Borgers
- 3,638
- 1
- 14
- 22
-
suggestion: get the root view by calling: `findViewById(android.R.id.content);` because it's the base Id of all activities. (I guess it's a FrameLayout, but not 100% sure) – Budius Jan 30 '14 at 13:14