Android View Children Get getAllChildren(View parentView, boolean recursive)

Here you can find the source of getAllChildren(View parentView, boolean recursive)

Description

get All Children

Declaration

public static Collection<View> getAllChildren(View parentView,
            boolean recursive) 

Method Source Code

//package com.java2s;
import java.util.ArrayList;
import java.util.Collection;

import android.view.View;
import android.view.ViewGroup;

public class Main {
    public static Collection<View> getAllChildren(View parentView,
            boolean recursive) {
        Collection<View> allViews = new ArrayList<View>();
        if (parentView instanceof ViewGroup) {
            for (int i = 0; i < ((ViewGroup) parentView).getChildCount(); ++i) {
                View child = ((ViewGroup) parentView).getChildAt(i);
                allViews.add(child);// w  w w  .j  a v  a  2s  . c  o m

                if (recursive)
                    allViews.addAll(getAllChildren(child, recursive));
            }
        }
        return allViews;
    }
}