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
精彩评论