Get all child views inside LinearLayout at once

前端 未结 6 2163
野性不改
野性不改 2020-11-28 04:39

I have a LinearLayout, which contains several child TextViews. How can I get child views of that LinerLayout using a loop?

6条回答
  •  Happy的楠姐
    2020-11-28 05:29

    It is easier with Kotlin using for-in loop:

    for (childView in ll.children) {
         //childView is a child of ll         
    }
    

    Here ll is id of LinearLayout defined in layout XML.

提交回复
热议问题