I have 3 relative layouts and i need to create a single setcontetntview which is a combination of these layouts each added 3 times and sharing equal screen space and it needs to be done programatically. I started by creating a new layout adding just 2 screens,
RelativeLayout primaryLayout = new RelativeLayout(this);
LayoutInflater layoutInflater = (LayoutInflater)this.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
RelativeLayout newLayout = (RelativeLayout)layoutInflater.inflate(R.layout.layout3, null, false);
RelativeLayout newLayout1 = (RelativeLayout)layoutInflater.inflate(R.layout.layout4, null, false);
primaryLayout.addView(newLayout);
primaryLayout.addView(newLayout1);
setContentView(primaryLayout);
This is displaying only the layout4. Also, if i add same layout again, its giving error stating the specified child already has a parent, you must call removeview() on the child parent first. Please help!