80,351
社区成员
发帖
与我相关
我的任务
分享
public class SymptomDerivationActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
int n=0;
LinearLayout layout= new LinearLayout(this);
while(n<1){
Button btn1 = new Button(this);
btn1.setWidth(75);
btn1.setHeight(25);
btn1.setText("测试"+n);
btn1.setOnClickListener(this.onClick(btn1));
layout.addView(btn1);
n++;
}
this.setContentView(layout);
}
public OnClickListener onClick(View v)
{
Toast.makeText(this, "test" , Toast.LENGTH_SHORT).show();
return null;
}
}