package com.example.addmultibtn;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
setContentView(ll);
Button bt[] = new Button[5];
for(int i=0; i<bt.length; i++){
bt[i] = new Button(this);
bt[i].setText("按鈕"+i);
ll.addView(bt[i]);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
留言列表