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.
Rega开发者_高级运维rds
AnshumanInside 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);
精彩评论