Android examples for User Interface:View Find
find View By Class
//package com.java2s; import android.view.View; import android.view.ViewGroup; public class Main { public static View findViewByClass(ViewGroup root, Class<?> c) { return parseViewGroup(root, c); }/*from ww w . j a v a 2 s . co m*/ private static View parseViewGroup(ViewGroup group, Class<?> c) { int n = group.getChildCount(); for (int i = 0; i < n; i++) { View view = group.getChildAt(i); if (c.isInstance(view)) { return view; } View result; if (view instanceof ViewGroup) { result = parseViewGroup((ViewGroup) view, c); if (result != null) { return result; } } } return null; } }