for(int i=0;i<n;i++)
{
Button btn = new Button(this);
btn.setLayoutParams(new LinearLayout.LayoutParams(150, 45));
btn.setId(i);
linearLayout.addView(btn);
try {
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v){
Intent userTry = new Intent(Ed.this,Op.class);
startActivity(userTry);
}
});
} catch (ActivityNotFoundException anfe) {
Log.e("onCreate", "Activity Not Found", anfe);
}
Android:我想动态创建按钮,以便将它的 id 传递给它去的下一个活动。但我收到一个错误。谢谢您的帮助