-5

There's nothing on this particular feature of Android in the documentation (for example here:

http://developer.android.com/reference/android/widget/Button.html#Button(android.content.Context)

How do i add a button to exsiting layout (or create a layout on runtime as well)?

And then, how do i apply attributes to said button i've just created?

4

1 回答 1

1

您可以从代码创建按钮。您可以在文档中找到设置属性的所有替代方法。例如

          Button button = new Button(this); 
          button.setText("hi"); 
          button.setId(Id);
          button.setTextColor(Color.Red);
          button.setBackgroundResource(R.drawable.icon);
          buttonlayout.addView(button); 
于 2013-05-19T15:32:38.267 回答