Search This Blog

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);
            }
        }
    }

No comments:

Post a Comment

Feedback always help in improvement. If you have any query suggestion feel free to comment and Keep visiting my blog to encourage me to blogging

Android News and source code