Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

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

public class Main {
    static void getSubviewsTree(ViewGroup parentView, Class<?> classOfSubviews, ArrayList<View> result) {
        for (int i = 0; i < parentView.getChildCount(); i++) {
            View child = parentView.getChildAt(i);
            if (classOfSubviews.isAssignableFrom(child.getClass()))
                result.add(child);
            if (child instanceof ViewGroup)
                getSubviewsTree((ViewGroup) child, classOfSubviews, result);
        }
    }

    public static ArrayList<View> getSubviewsTree(ViewGroup parentView, Class<?> classOfSubviews) {
        ArrayList<View> result = new ArrayList<View>();
        getSubviewsTree(parentView, classOfSubviews, result);
        return result;
    }
}