Created
September 17, 2013 07:50
-
-
Save laaptu/6591247 to your computer and use it in GitHub Desktop.
Method to disable or enable child view of a view group or view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
*http://stackoverflow.com/questions/5418510/disable-the-touch-events-for-all-the-views | |
* Enables/Disables all child views in a view group. | |
* | |
* @param viewGroup the view group | |
* @param enabled <code>true</code> to enable, <code>false</code> to disable | |
* the views. | |
*/ | |
public static void enableDisableViewGroup(ViewGroup viewGroup, boolean enabled) { | |
int childCount = viewGroup.getChildCount(); | |
for (int i = 0; i < childCount; i++) { | |
View view = viewGroup.getChildAt(i); | |
view.setEnabled(enabled); | |
if (view instanceof ViewGroup) { | |
enableDisableViewGroup((ViewGroup) view, enabled); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment