Here you can find the source of getSubviewsTree(ViewGroup parentView, Class> classOfSubviews)
public static ArrayList<View> getSubviewsTree(ViewGroup parentView, Class<?> classOfSubviews)
//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);/*from w w w .j a v a 2 s . c o m*/ 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; } }