如何为动态创建的多个按钮创建单击侦听器?这是我的代码。
int cn = myary.length;
ScrollView sv = new ScrollView(this);
TableLayout ll = new TableLayout(this);
HorizontalScrollView hsv = new HorizontalScrollView(this);
TableRow tbrow0 = new TableRow(this);
EditText tv0 = new EditText(this);
tv0.setText("");
tbrow0.addView(tv0);
ll.addView(tbrow0);
int j = 0;
for (int i = 0; i < cn; i++) {
TableRow tbrow = new TableRow(this);
t1v = new Button(this);
t1v.setText(myary[i]);
t1v.setId(i+j);
tbrow.addView(t1v);
ll.addView(tbrow);
}
hsv.addView(ll);
sv.addView(hsv);
setContentView(sv);