Android examples for User Interface:ViewGroup
get ViewGroup Body Text
//package com.java2s; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; public class Main { public static String getBodyText(ViewGroup contentView) { return getText(contentView, new int[] { 1, 0 }); }/*w w w.j av a2s . c om*/ public static String getText(ViewGroup contentView, int[] path) { View view = getView(contentView, path); if (!(view instanceof TextView)) { return ""; } return ((TextView) view).getText().toString(); } public static View getView(ViewGroup root, int[] path) { ViewGroup current = root; for (int i = 0; i < path.length; i++) { if (current.getChildCount() <= path[i]) { return null; } View child = current.getChildAt(path[i]); if (i == path.length - 1) { return child; } if (!(child instanceof ViewGroup)) { return null; } current = (ViewGroup) child; } return null; } }