You need to do something like:
Button myButton = new Button(this);
myButton.setText("Click Me!");
LinearLayout ln = (LinearLayout)findViewById(R.id.buttonlayout);
LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
ln.addView(myButton, lp);