List of usage examples for android.view ViewGroup getChildCount
public int getChildCount()
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);//from www . j a va 2 s . com enableAllChildren(child); } } }
From source file:Main.java
public static void disableAllChildren(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(false);// w ww.j a v a2 s . com disableAllChildren(child); } } }
From source file:Main.java
/** * Disable all the childs of the selected root view * * @param rootView View to iterate in order to disable all its childs * @param alpha Alpha to set to disabled elements *//*from w ww .ja v a2 s. c o m*/ public static void disableView(ViewGroup rootView, float alpha) { int count = rootView.getChildCount(); View v; //Go over the child list of the view and disable all for (int i = 0; i < count; i++) { v = rootView.getChildAt(i); if (v != null) { if (v instanceof ViewGroup) disableView((ViewGroup) v, alpha); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) v.setAlpha(alpha); v.setEnabled(false); } } }
From source file:Main.java
/** * Invalidates a view and all of its descendants. *///from ww w. j a v a 2 s . c om private static void recursiveInvalidate(View view) { view.invalidate(); if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; int childCount = group.getChildCount(); for (int i = 0; i < childCount; i++) { View child = group.getChildAt(i); if (child.getVisibility() == View.VISIBLE) { recursiveInvalidate(child); } } } }
From source file:Main.java
private static void setCustomFont(ViewGroup v) { final int len = v.getChildCount(); processsViewGroup(v, len);//from www . j a va 2 s . com }
From source file:Main.java
public static void clearAllEdits(ViewGroup group) { if (group != null) { int count = group.getChildCount(); for (int i = 0; i < count; ++i) { View view = group.getChildAt(i); if (view instanceof EditText) { ((EditText) view).setText(""); } else if (view instanceof LinearLayout) { clearAllEdits((ViewGroup) view); }//from w w w. ja v a 2s .c o m } } }
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 av a 2 s.co m*/ } } } } return parent; }
From source file:Main.java
/** * Set typeface for a viewgroup//from w w w . j a v a 2 s . co m * * @param typeFace * @param parent */ public static void setTypeFace(Typeface typeFace, ViewGroup parent) { for (int i = 0; i < parent.getChildCount(); i++) { View v = parent.getChildAt(i); if (v instanceof ViewGroup) setTypeFace(typeFace, (ViewGroup) v); else if (v instanceof TextView) setTypeFace(typeFace, (TextView) v); } }
From source file:Main.java
public static void findAllViews(ViewGroup parent, List<View> views, Class type) { for (int i = 0; i < parent.getChildCount(); i++) { View child = parent.getChildAt(i); if (child instanceof ViewGroup && child.getClass() != type) { findAllViews((ViewGroup) child, views, type); } else if (child != null) { if (child.getClass() == type) { views.add(child);//from w w w . j a va2s . c om } } } }
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); if (view.isFocusable()) view.setEnabled(enabled);//from w w w .jav a2 s .com if (view instanceof ViewGroup) { enableDisableViewGroup((ViewGroup) view, enabled); } else if (view instanceof ListView) { if (view.isFocusable()) view.setEnabled(enabled); ListView listView = (ListView) view; int listChildCount = listView.getChildCount(); for (int j = 0; j < listChildCount; j++) { if (view.isFocusable()) listView.getChildAt(j).setEnabled(false); } } } }