Search This Blog

Support my cause by downloading

Monday, 25 November 2013

how to disable nested ViewGroup's (RelativeLayout,LinearLayout etc) childs android

This is tutorial is a part android Utility functions, ViewGroup, View disable and enable

I created one function for disabling all View of any child whether its LinearLayout, RelativeLayout or anything. It will go through complete View Hierarchy and will disable all View contains inside parent. This function call recursive and work even if ViewGroup contains another ViewGroup too.
Enjoy by running it

    public void disableAllSettings(ViewGroup mGroup) {

        int itotal = mGroup.getChildCount();
        for (int i = 0; i < itotal; i++) {
            if (mGroup.getChildAt(i) instanceof ViewGroup) {
                disableAllSettings((ViewGroup) mGroup.getChildAt(i));
            } else {
                mGroup.getChildAt(i).setEnabled(false);
            }
        }
    }
Android News and source code