Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.os.Build;

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

public class Main {
    /**
     * 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
     */
    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);
            }
        }
    }
}