I am making an Android app, and I want to copy some XML code in a Linear Layout, and re-insert it into the Linear Layout so that there are two of the Relative Layouts in the
Inflating the same layout inside it once again might help you achieve this.
Try this code:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_layout);
LinearLayout main_layout = (LinearLayout)findViewById(R.id.tileContainerME);
LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout child = (LinearLayout) inflater.inflate(R.layout.main_layout, null);
main_layout.addView(child, 1);
}
You'll get something like this: