title: Replacing Child fragments
body: <p>I'm a newbie to Android development. Im using Xamarin Android to develop an Android Application. im having problems when replacing fragments within the fragments, working on a Template app where i want to replace the FragmentA with FragmentB. Within the Main Activity, the content_frame is being replaced by FragmentA.</p>
  
  <p>here is the Code i currently have</p>
  
  <p>Main.axml  </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
          &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:orientation="vertical"&gt;
              &lt;TextView
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:textAppearance="?android:attr/textAppearanceLarge"
                  android:text="MAIN ACTIVITY" /&gt;
              &lt;FrameLayout
                  android:id="@+id/parent_fragment"
                  android:layout_width="fill_parent"
                  android:layout_height="200dip" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>MainActivity.cs</p>
  
  <pre><code>[Activity(Label = "NestedFrags", MainLauncher = true, Icon = "@drawable/icon")]
      public class MainActivity : Activity
      {
          int count = 1;
  
          protected override void OnCreate(Bundle bundle)
          {
              base.OnCreate(bundle);
  
              // Set our view from the "main" layout resource
              SetContentView(Resource.Layout.Main);
  
              Fragment fragA = new FragmentA();
              FragmentManager.BeginTransaction().Replace(Resource.Id.parent_fragment, fragA).Commit();
          }
      }
  </code></pre>
  
  <p>FragmentA.axml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:minWidth="25px"
      android:minHeight="25px"&gt;
      &lt;TextView
          android:text="Parent Fragment"
          android:textAppearance="?android:attr/textAppearanceLarge"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:id="@+id/textView1" /&gt;
      &lt;FrameLayout
          android:id="@+id/child_fragment"
          android:layout_width="fill_parent"
          android:layout_height="200dip" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>FragmentA.cs</p>
  
  <pre><code>public class FragmentA : Fragment
      {
          public override void OnCreate(Bundle savedInstanceState)
          {
              Fragment fragmentB = new FragmentB();
              FragmentTransaction transaction = ChildFragmentManager.BeginTransaction();
              transaction.Add(Resource.Id.child_fragment, fragmentB).Commit();
              base.OnCreate(savedInstanceState);
          }
  
          public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
          {
              View view = inflater.Inflate(Resource.Layout.fraga, container, false);
              return view;
          }
      }
  </code></pre>
  
  <p>FragmentB.axml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:minWidth="25px"
      android:minHeight="25px"&gt;
      &lt;TextView
          android:text="Child Fragment of A"
          android:textAppearance="?android:attr/textAppearanceLarge"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:id="@+id/textView2" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>FragmentB.cs</p>
  
  <pre><code> public class FragmentB : Fragment
      {
          public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
          {
              View view = inflater.Inflate(Resource.Layout.fragb, container, false);
              return view;
          }
      }
  </code></pre>
  
  <p>Until now, im able to replace the Fragments one on top of another. but im trying to replace the fragmentA completely with fragmentB. Can anyone please help me? I dont mind if anyone can answer in Java as i just need something to work with, i will make changes to my code according to Java solution. </p>
  
  <p>Thanks in Advance for all or any help.</p>