Both containers have the exact same name..eventContainerSub.
There is no eventContainer, change the view group to be the container as you planned..
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:id="@+id/event_container"
android:weightSum="100"
android:duplicateParentState="true">
and make sure the code is asking for the right Ids:
final LinearLayout eventContainerSub = (LinearLayout) findViewById(R.layout.eventContainerSub);
final LinearLayout eventContainer =
(LinearLayout) findViewById(R.id.event_container);
I'd also suggest you first remove the SubContainer from the view if it got inflated, as that view already has a parent and you cannot attach the SubContainer to two parents.
Either leave the subcontainer from this file and create a new one, or remove from the parent and only then add to the ViewGroup you want.
Android layout replacing a view with another view on run time