Example usage for android.view ViewGroup getChildCount

List of usage examples for android.view ViewGroup getChildCount

Introduction

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

Prototype

public int getChildCount() 

Source Link

Document

Returns the number of children in the group.

Usage

From source file:Main.java

/**
 * Searches a {@link ViewGroup} for the first {@link ImageView} it can find in its child views.
 *
 * @param container The container {@link ViewGroup}.
 * @return The first {@link ImageView} in the {@code container ViewGroup} (counted by child
 * indexes), or {@code null} if no {@code ImageView} was found.
 *//*  w w  w.  j  av  a  2s  .co  m*/
public static ImageView findFirstImageView(ViewGroup container) {
    for (int i = 0; i < container.getChildCount(); i++) {
        View v = container.getChildAt(i);
        if (v instanceof ImageView) {
            return (ImageView) v;
        } else if (v instanceof ViewGroup) {
            return findFirstImageView((ViewGroup) v);
        }
    }
    return null;
}

From source file:Main.java

public static boolean IsFormCompleted(ViewGroup v) {
    for (int i = 0; i < v.getChildCount(); i++) {
        Object child = v.getChildAt(i);

        if (child instanceof EditText) {
            EditText e = (EditText) child;

            if (e.getText().length() == 0)
                return false;
        } else if (child instanceof RadioGroup) {
            RadioGroup rb = (RadioGroup) child;

            if (rb.getCheckedRadioButtonId() < 0)
                return false;
        }// ww  w  .  jav a2s .c om
    }

    return true;
}

From source file:Main.java

public static void SetEnableControls(boolean enable, ViewGroup vg) {
    try {/*from   www .j a  va 2s. co  m*/
        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

public static void enableDisableViewGroup(ViewGroup viewGroup, boolean enabled) {
    int childCount = viewGroup.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View view = viewGroup.getChildAt(i);
        view.setEnabled(enabled);//  w  w  w .  j  a  v  a  2  s .  c  o  m
        if (view instanceof ViewGroup) {
            enableDisableViewGroup((ViewGroup) view, enabled);
        }
    }
}

From source file:Main.java

public static void enableDisableView(View view, boolean enabled) {
    view.setEnabled(enabled);//  w  w w .  ja  v  a2  s  .co 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

private static void setDialogFontSize(View view, int size) {
    if (view instanceof ViewGroup) {
        ViewGroup parent = (ViewGroup) view;
        int count = parent.getChildCount();
        for (int i = 0; i < count; i++) {
            setDialogFontSize(parent.getChildAt(i), size);
        }/*from w w w .  j  a va2s  . c  om*/
    } else if (view instanceof TextView) {
        TextView textview = (TextView) view;
        textview.setTextSize(size);
    }
}

From source file:Main.java

private static int calculateParallaxLayersRecursively(View view, int count) {
    if (view instanceof ViewGroup) {
        ViewGroup group = (ViewGroup) view;
        for (int i = 0; i < group.getChildCount(); i++) {
            count = calculateParallaxLayersRecursively(group.getChildAt(i), count);
        }//from   w w  w .  j  a v  a 2 s  . c o m
    } else {
        count++;
    }
    return count;
}

From source file:Main.java

private static int calculateParallaxLayers(View view) {
    if (view instanceof ViewGroup) {
        ViewGroup group = (ViewGroup) view;
        return group.getChildCount();
    }//  w w  w  .  j  a  v a 2 s. c o m
    return 1;
}

From source file:Main.java

public static void setViewClickable(View view, boolean clickable) {
    view.setClickable(clickable);/* w w  w. j  av  a 2  s.  c o m*/

    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

private static int calculateParallaxLayersRecursively(View view, int startCount) {
    int count = startCount;
    if (view instanceof ViewGroup) {
        ViewGroup group = (ViewGroup) view;
        for (int i = 0; i < group.getChildCount(); i++) {
            count = calculateParallaxLayersRecursively(group.getChildAt(i), count);
        }//from w  w w.j  a v a2s .  c o  m
    } else {
        count++;
    }
    return count;
}