Android examples for User Interface:ViewGroup
Recursively sets enabled flag for all views contained in viewGroup.
//package com.java2s; import android.view.View; import android.view.ViewGroup; public class Main { /**// ww w . ja va 2s . c o m * Recursively sets enabled flag for all views contained in viewGroup. * Very useful for something like settings screens, when you need to enable/disable all controls * inside a layout via Switch, RadioButton or CheckBox * * @param viewGroup * which children will be enabled/disabled * @param isEnabled * true or false to set */ public static void setEnabledForAllChildrenRecursively( final ViewGroup viewGroup, final boolean isEnabled) { for (int i = 0; i < viewGroup.getChildCount(); i++) { final View child = viewGroup.getChildAt(i); if (child == null) continue; child.setEnabled(isEnabled); if (child instanceof ViewGroup) { setEnabledForAllChildrenRecursively((ViewGroup) child, isEnabled); } } } }