枚举/迭代活动中的所有视图? [英] Enumerate/Iterate all Views in Activity?
本文介绍了枚举/迭代活动中的所有视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法遍历 Activity 中的所有视图?比如:
Is there a way to iterate through all the views in your Activity? Something like:
Iterator it = getViewIterator();
...
这真的存在吗?
推荐答案
如果你的所有视图都在 LinearLayout
或其他扩展 ViewGroup 的
您可以使用函数 container
中getChildCount()
和 getChildAt(int)
并遍历所有
包含视图.
If you have all your Views in a LinearLayout
or an other container
that extends ViewGroup
you can use the functions getChildCount()
and getChildAt(int)
and iterate through all of the
contained views.
希望这会有所帮助.
这篇关于枚举/迭代活动中的所有视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文