为了账号安全,请及时绑定邮箱和手机立即绑定

如何在Android中动态添加按钮?

如何在Android中动态添加按钮?

繁花如伊 2019-08-03 13:03:35
如何在Android中动态添加按钮?如何在Android中动态添加按钮?
查看完整描述

3 回答

?
有只小跳蛙

TA贡献1824条经验 获得超8个赞

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);

看一看这,这个



查看完整回答
反对 回复 2019-08-04
?
浮云间

TA贡献1829条经验 获得超4个赞

试试这个:

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);


 

查看完整回答
反对 回复 2019-08-04
  • 3 回答
  • 0 关注
  • 278 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号