Android examples for User Interface:View Child
get View List from all child view
import java.util.ArrayList; import java.util.List; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; public class Main { private static List<View> getViewList(List<View> allChildViews) { List<View> allViewsList = new ArrayList<View>(); for (View child : allChildViews) { if ((child instanceof ViewGroup) || (child instanceof ImageView) || (child instanceof TextView)) { } else if (child instanceof View) { allViewsList.add(child);//from ww w. ja va 2 s .c o m } } return allViewsList; } public static List<View> getViewList(View view) { return getViewList(getAllChildView(view)); } public static List<View> getAllChildView(View view) { List<View> allChildView = new ArrayList<View>(); if (view instanceof ViewGroup) { ViewGroup vg = (ViewGroup) view; for (int i = 0; i < vg.getChildCount(); i++) { View viewChild = vg.getChildAt(i); allChildView.add(viewChild); allChildView.addAll(getAllChildView(viewChild)); } } return allChildView; } }