如何在Android中動(dòng)態(tài)添加按鈕?如何在Android中動(dòng)態(tài)添加按鈕?
3 回答

倚天杖
TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超3個(gè)贊
Button myButton = new Button(this); myButton.setText("Push Me"); LinearLayout ll = (LinearLayout)findViewById(R.id.buttonlayout); LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); ll.addView(myButton, lp);

湖上湖
TA貢獻(xiàn)2003條經(jīng)驗(yàn) 獲得超2個(gè)贊
LinearLayout ll = (LinearLayout)findViewById(R.id.layout);Button btn = new Button(this);btn.setText("Manual Add"); btn.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));ll.addView(btn);
- 3 回答
- 0 關(guān)注
- 1898 瀏覽
添加回答
舉報(bào)
0/150
提交
取消