Enumerate/Iterate all Views in Activity?

后端 未结 8 569
忘了有多久
忘了有多久 2020-12-09 17:33

Is there a way to iterate through all the views in your Activity? Something like:

Iterator it = getViewIterator();
...

Does this exi

8条回答
  •  执念已碎
    2020-12-09 17:50

    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.

    Hope this helps.

提交回复
热议问题