get Buttons List from View - Android User Interface

Android examples for User Interface:Button

Description

get Buttons List from View

Demo Code


//package com.java2s;
import java.util.ArrayList;

import java.util.List;
import android.view.View;
import android.widget.Button;

public class Main {
    public static List<Button> getButtonsList(View container) {
        List<Button> list = new ArrayList<Button>();
        List<View> views = container.getTouchables();
        for (View view : views) {
            if (view instanceof Button) {
                list.add((Button) view);
            }// w  w w. j a v  a  2  s  .  co m
        }
        return list;
    }
}

Related Tutorials