Adham Adham - 1 year ago 102
Android Question

Get all child views inside LinearLayout at once

I have a

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

Answer Source

Use getChildCount() and also getChildAt().


LinearLayout ll = …
final int childcount = ll.getChildCount();
for (int i = 0; i < childcount; i++) {
      View v = ll.getChildAt(i);
      // Do something with v.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download