动态添加按钮?
答
这就是你可以在运行时添加一个按钮,一组:线性布局
final ViewGroup group = (ViewGroup)findViewById(R.id.some_group);
final Button button = new Button(context);
button.setText("Some text");
group.addView(button,
new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
答
setContentView(R.layout.medplan_index);
采取定向垂直。
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.linearLayout);
Button btn = new Button (this);
btn.setText("button name");
btn.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
linearLayout.addView(btn);
哦,我的朋友!请阅读http://stackoverflow.com/questions/how-to-ask – 2011-05-05 07:06:05
你想在哪里动态添加按钮? – Pasha 2011-05-05 07:06:32