Example usage for android.view ViewGroup getChildAt

List of usage examples for android.view ViewGroup getChildAt

Introduction

In this page you can find the example usage for android.view ViewGroup getChildAt.

Prototype

public View getChildAt(int index) 

Source Link

Document

Returns the view at the specified position in the group.

Usage

From source file:Main.java

/**
 * Take screenshot of the activity including the action bar
 * /*from   ww w.java  2  s  .  c  om*/
 * @param activity
 * @return The screenshot of the activity including the action bar
 */
public static Bitmap takeScreenshot(Activity activity) {
    ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView();
    ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
    decorChild.setDrawingCacheEnabled(true);
    decorChild.buildDrawingCache();
    Bitmap drawingCache = decorChild.getDrawingCache(true);
    Bitmap bitmap = Bitmap.createBitmap(drawingCache);
    decorChild.setDrawingCacheEnabled(false);
    return bitmap;
}

From source file:Main.java

public static void SetEnableControls(boolean enable, ViewGroup vg) {
    try {//from   w  ww.  jav a2 s.c om
        for (int i = 0; i < vg.getChildCount(); i++) {
            View child = vg.getChildAt(i);
            child.setEnabled(enable);
            if (child instanceof ViewGroup) {
                SetEnableControls(enable, (ViewGroup) child);
            }
        }
    } catch (Exception ex) {/* Do nothing */
    }
}

From source file:Main.java

private static void makeHtml(ViewGroup viewGroup) {
    for (int i = 0; i < viewGroup.getChildCount(); i++) {
        final View childView = viewGroup.getChildAt(i);
        if (childView instanceof TextView) {
            final TextView curr = (TextView) childView;
            curr.setText(Html.fromHtml(curr.getText().toString()));
        }/*  w w  w.j  av a  2 s  . co  m*/

        if (childView instanceof ViewGroup) {
            makeHtml((ViewGroup) childView);
        }
    }
}

From source file:Main.java

public static void dismissChildren(ViewGroup viewgroup) {
    int i1 = viewgroup.getChildCount();
    for (int j1 = 0; j1 < i1; j1++) {
        viewgroup.getChildAt(j1).setVisibility(4);
    }/*  www .ja va2  s  .c  o m*/

    viewgroup.setVisibility(8);
}

From source file:Main.java

public static void showChildren(ViewGroup viewgroup) {
    int i1 = viewgroup.getChildCount();
    for (int j1 = 0; j1 < i1; j1++) {
        viewgroup.getChildAt(j1).setVisibility(0);
    }//w  w w  .  j  av  a  2 s .  c o  m

    viewgroup.setVisibility(0);
}

From source file:Main.java

public static View getContentView(View parent) {
    if (parent instanceof ViewGroup) {
        ViewGroup group = (ViewGroup) parent;
        for (int i = 0; i < group.getChildCount(); i++) {
            if (group.getChildAt(i) instanceof ViewGroup) {
                ViewGroup group2 = (ViewGroup) group.getChildAt(i);
                for (int j = 0; j < group2.getChildCount(); j++) {
                    if (group2.getChildAt(j) instanceof ViewGroup) {
                        return group2.getChildAt(j);
                    }//from   w  w w . j a va2 s .c om
                }
            }
        }
    }
    return parent;
}

From source file:Main.java

public static void enableDisableView(View view, boolean enabled) {
    view.setEnabled(enabled);// w w  w  . j a  va2 s.c  o  m
    if (view instanceof ViewGroup) {
        ViewGroup group = (ViewGroup) view;
        for (int id = 0; id < group.getChildCount(); id++) {
            enableDisableView(group.getChildAt(id), enabled);
        }
    }
}

From source file:Main.java

public static View findViewByClassName(ViewGroup v, String viewClassName) {
    View a;//from   www . j  ava  2  s.c o m
    for (int i = 0; i < v.getChildCount(); i++) {
        a = v.getChildAt(i);
        if (a.getClass().getName().equals(viewClassName))
            return a;

        if (ViewGroup.class.isAssignableFrom(a.getClass())) {
            View b = findViewByClassName((ViewGroup) a, viewClassName);
            if (b != null)
                return b;
        }
    }
    return null;
}

From source file:Main.java

public static void setViewClickable(View view, boolean clickable) {
    view.setClickable(clickable);// www.j a  v a  2s. c om

    if (view instanceof ViewGroup) {
        ViewGroup group = (ViewGroup) view;

        for (int i = 0; i < group.getChildCount(); i++) {
            setViewClickable(group.getChildAt(i), clickable);
        }
    }
}

From source file:Main.java

public static void enableAllChildren(View view) {
    if (view instanceof ViewGroup) {
        ViewGroup viewGroup = (ViewGroup) view;
        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            View child = viewGroup.getChildAt(i);
            child.setEnabled(true);/*  www  . ja v  a2 s. c o  m*/
            enableAllChildren(child);
        }
    }
}