How to find all child controls in an Activity (Android)
How do I find all child controls in an Activity. I want to get an enumeration 开发者_StackOverflowof all EditTexts, Spinnners and Checkboxes at runtime.
Thanks
You can't get a direct enumeration. You'll have to do a recursive walk using ViewGroup#getChildCount
coupled with ViewGroup#getChildAt
. Then you'll have to test using instanceof
and process each view however you want depending on its type.
精彩评论