How to add a button dynamically in Android?
Try this:
LinearLayout ll = (LinearLayout)findViewById(R.id.layout); Button btn = new Button(this); btn.setText("Manual Add"); btn.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); ll.addView(btn);