set View Enabled Recursive - Android User Interface

Android examples for User Interface:View Enable

Description

set View Enabled Recursive

Demo Code

//   Licensed under the Apache License, Version 2.0 (the "License");
import android.view.View;
import android.view.ViewGroup;

public class Main{
    private final static String TAG = "";
    private final static boolean VERBOSE = false;
    public static void setEnabledRecursive(ViewGroup viewGroup,
            boolean enabled) {
        Log.vc(VERBOSE, TAG, "setEnabledRecursive: viewGroup=" + viewGroup
                + ", enabled=" + enabled);
        final int children = viewGroup.getChildCount();
        for (int i = 0; i < children; i++) {
            View view = viewGroup.getChildAt(i);
            view.setEnabled(enabled);/*w  w  w  . jav a2  s.  c  o m*/

            if (view instanceof ViewGroup) {
                setEnabledRecursive((ViewGroup) view, enabled);
            }
        }
    }
}

Related Tutorials