If I for example have empty layout like this:
Try this method
Add id to LinearLayout 'layout1.xml':
In onCreate:
LinearLayout firstlayout = (LinearLayout) findViewById(R.id.firstlayout);
LinearLayout secondlayoout = (LinearLayout) this.getLayoutInflater().inflate(R.layout.layout2, null); // inflating view from xml
TextView btn1 = (TextView) secondlayoout.findViewById(R.id.button1);
btn1.setText("TEST");
firstlayout.addView(secondlayoout);