Created
March 3, 2016 02:15
-
-
Save fanglinchen/cd02b1f61d08df351399 to your computer and use it in GitHub Desktop.
Loop through all subviews of an Android view
This file contains hidden or 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
public void recursiveLoopChildren(ViewGroup parent) { | |
for (int i = parent.getChildCount() - 1; i >= 0; i--) { | |
final View child = parent.getChildAt(i); | |
if (child instanceof ViewGroup) { | |
recursiveLoopChildren((ViewGroup) child); | |
// DO SOMETHING WITH VIEWGROUP, AFTER CHILDREN HAS BEEN LOOPED | |
} else { | |
if (child != null) { | |
// DO SOMETHING WITH VIEW | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment