When the user presses a button, I would like fragment B to appear on the left, like this:

Here is my code right now to do this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<ViewGroup
android:id="@+id/leftContainer"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#ffff0000" />
<ViewGroup
android:id="@+id/rightContainer"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="#ff00ffff" />
</LinearLayout>
android.support.v4.app.FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.add(R.id.leftContainer, fragmentA);
ft.add(R.id.rightContainer, fragmentB);
ft.commit();
Unfortunately, all this gives me is a black screen. I do not even see the background colors for the fragments.
The answer is to:
Then when needed: