Android examples for User Interface:View Tag
get Views By Tag Prefix
//package com.java2s; import android.view.View; import android.view.ViewGroup; import java.util.ArrayList; import java.util.List; public class Main { public static List<View> getViewsByTagPrefix(ViewGroup root, String tagPrefix) {//from www .j av a 2 s . co m List<View> views = new ArrayList<>(); final int childCount = root.getChildCount(); for (int i = 0; i < childCount; i++) { final View child = root.getChildAt(i); if (child instanceof ViewGroup) { views.addAll(getViewsByTagPrefix((ViewGroup) child, tagPrefix)); } final Object tagObj = child.getTag(); if (tagObj != null && tagObj.toString().startsWith(tagPrefix)) { views.add(child); } } return views; } }