-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?

Dravic
  • 29
  • 6

1 Answers1

1

you can create button from code. you can find all the alternative methods of setting attribute in the doc. for example

          Button button = new Button(this); 
          button.setText("hi"); 
          button.setId(Id);
          button.setTextColor(Color.Red);
          button.setBackgroundResource(R.drawable.icon);
          buttonlayout.addView(button); 
stinepike
  • 54,068
  • 14
  • 92
  • 112