Reputation: 4559
I want to create an array of buttons in my app. So how that can be done. Secondly, is it possible to interact with each button in an array of buttons? If so, how? Please suggest to me.
Regards
Anshuman
Upvotes: 3
Views: 7576
Reputation: 4003
Inside you Activity do something like this:
LinearLayout linear = new LinearLayout(this);
linear.setOrientation(LinearLayout.VERTICAL);
ArrayList<Button> ab = new ArrayList<Button>();
for (Button b : ab) {
linear.addView(b);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
});
};
setContentView(linear);
Upvotes: 3