Set Enable Controls for ViewGroup - Android User Interface

Android examples for User Interface:ViewGroup

Description

Set Enable Controls for ViewGroup

Demo Code


//package com.java2s;

import android.view.View;
import android.view.ViewGroup;

public class Main {
    public static void SetEnableControls(boolean enable, ViewGroup vg) {
        try {/*from w  w w.  ja  v  a 2  s  . c o  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 */
        }
    }
}

Related Tutorials