find View By Ids - Android User Interface

Android examples for User Interface:View Find

Description

find View By Ids

Demo Code


//package com.java2s;

import android.view.View;
import android.view.ViewGroup;

import java.util.List;

public class Main {
    public static void findViewByIds(View view, int tag, List<View> views) {
        if (tag == view.getId()) {
            views.add(view);/*from   w  w w .  ja va2 s.  co  m*/

        }
        if (view instanceof ViewGroup) {
            ViewGroup group = (ViewGroup) view;
            View child = null;
            for (int i = 0; i < group.getChildCount(); i++) {
                child = group.getChildAt(i);
                findViewByIds(child, tag, views);
            }
            return;
        }
        return;
    }
}

Related Tutorials