How to construct a button on runtime (Android) [closed]

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

Leave a Comment