开发者

How to find all child controls in an Activity (Android)

开发者 https://www.devze.com 2023-02-02 01:55 出处:网络
How do I find all child controls in an Activity. I want to get an enumeration 开发者_StackOverflowof all EditTexts, Spinnners and Checkboxes at runtime.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消