sachit
sachit

Reputation: 1138

Widgets of an Activity

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?

Upvotes: 0

Views: 45

Answers (1)

Toon Borgers
Toon Borgers

Reputation: 3658

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.

Upvotes: 3

Related Questions