Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
private static ArrayList<View> getViewsByTag(ViewGroup root, String tag){
ArrayList<View> views = new ArrayList<View>();
final int childCount = root.getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = root.getChildAt(i);
if (child instanceof ViewGroup) {
views.addAll(getViewsByTag((ViewGroup) child, tag));
final Object tagObj = child.getTag();
if (tagObj != null && tagObj.equals(tag)) {
return views;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment