开发者

How to create multiple buttons at runtime?

In开发者_运维知识库 my Android application, I have to add multiple buttons at runtime at the base of the screen. How can I add onClick listener to each button when adding them?


You could create a LinearLayout or whatever on the Eclipse Designer, and put it at the bottom. About the button creation:

Button b = new Button(this); // Assuming it's in your activity
LinearLayout ll = (LinearLayout)findViewById(R.id.myLayoutAtTheBottom); // It could not be a LinearLayout, of course
ll.addView(b);

And so on for each button.


You can add as many button as you wish at runtime with Button b = new Button(this); code /...:) wts the problem

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜