title: How to add child fragment inside parent fragment android?
body: <p>I have main layout. I want to add fragment in main LinearLayout. But if I want to add child fragment in main fragment, it is currently present and visible.</p>
  
  <pre><code>&lt;LinearLayout
      android:id="@+id/linearlayout_fragment"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_above="@+id/footer"
      android:layout_below="@id/header"
      android:orientation="vertical" &gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>In Fragment activity, I added this: </p>
  
  <pre><code>FragmentManager fragmentManager = getSupportFragmentManager();
  FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
  
  HomeFragment homeFragment = HomeFragment.newInstance();
  homeFragment.setRetainInstance(true);
  fragmentTransaction.replace(R.id.linearlayout_fragment, homeFragment);
  fragmentTransaction.commit();
  </code></pre>
  
  <p>Now I want to add child fragment in current home fragment:</p>
  
  <pre><code>FragmentManager fragmentManager = getChildFragmentManager();
  FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
  
  RepairFragment repairFragment = RepairFragment.newInstance();
  repairFragment.setRetainInstance(true);
  fragmentTransaction.add(R.id.linearlayout_fragment, repairFragment);
  fragmentTransaction.commit();
  </code></pre>
  
  <p>But I got Exception:</p>
  
  <pre><code>04-15 11:18:26.394: E/AndroidRuntime(12561): FATAL EXCEPTION: main
  04-15 11:18:26.394: E/AndroidRuntime(12561): java.lang.IllegalArgumentException: No view found for id 0x7f070005 (com.test.simple:id/linearlayout_fragment) for fragment RepairFragment{42319fb0 #0 id=0x7f070005}
  04-15 11:18:26.394: E/AndroidRuntime(12561):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:919)
  04-15 11:18:26.394: E/AndroidRuntime(12561):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
  04-15 11:18:26.394: E/AndroidRuntime(12561):    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
  04-15 11:18:26.394: E/AndroidRuntime(12561):    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
  04-15 11:18:26.394: E/AndroidRuntime(12561):    at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:440)
  04-15 11:18:26.394: E/AndroidRuntime(12561):    at android.os.Handler.handleCallback(Handler.java:730)
  04-15 11:18:26.394: E/AndroidRuntime(12561):    at android.os.Handler.dispatchMessage(Handler.java:92)
  04-15 11:18:26.394: E/AndroidRuntime(12561):    at android.os.Looper.loop(Looper.java:176)
  04-15 11:18:26.394: E/AndroidRuntime(12561):    at android.app.ActivityThread.main(ActivityThread.java:5493)
  04-15 11:18:26.394: E/AndroidRuntime(12561):    at java.lang.reflect.Method.invokeNative(Native Method)
  04-15 11:18:26.394: E/AndroidRuntime(12561):    at java.lang.reflect.Method.invoke(Method.java:525)
  04-15 11:18:26.394: E/AndroidRuntime(12561):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1225)
  04-15 11:18:26.394: E/AndroidRuntime(12561):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1041)
  04-15 11:18:26.394: E/AndroidRuntime(12561):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>I tried:</p>
  
  <pre><code>fragmentTransaction.replace(getParentFragment().getId(), repairFragment);
  fragmentTransaction.replace(getView().getId(), repairFragment);
  </code></pre>