title: Android adding Fragment inside Fragment
body: <p>Hi there (and thanks in advance),</p>
  
  <p>I have an application with a Google Play Store-like layout (using PagerTabStrip with 5 sub fragments). In some of those fragments I will need to display a little info regarding the last time the data was updated.</p>
  
  <p>I immediately thought of creating a fragment (LastUpdatedFragment) which I would then add (nest) to the fragments I needed. At first, and since the last updated date was supposed to be the same for every screen, things were working (I simply added the fragment in the xml of the parent Fragments I needed and inside onCreateView I would put the date in the TextView), but after some changes I now need to send a specific date for each one of these LastUpdatedFragment instances.</p>
  
  <p>I came up with one way - creating new custom attributes for my Fragment and then I would set the date I wanted. After some reading I stumbled across a easier way (<a href="https://stackoverflow.com/questions/6847460/fragments-within-fragments/11020531#11020531">Fragments within Fragments</a> - dinamically adding the fragment using FragmentManager) - I simply needed the parent Fragment to handle the input parameters and pass it to the child fragment.</p>
  
  <p>The problem is that, although I get no errors I also get no child fragment, it just does not display. I would be grateful if you could guide me in the right direction.</p>
  
  <p><strong>ScoreBoardFragment.java -> Parent Fragment</strong></p>
  
  <pre><code>    @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
  
          rootView = inflater.inflate(R.layout.fragment_scoreboard, container,
                  false);
  
          for (int i = 0; i &lt; tvCount; i++) {
              tvName = "f_scoreboard_header_tv" + String.valueOf(i);
              resID = getResources().getIdentifier(tvName, "id",
                      _activity.getPackageName());
              header = (TextView) rootView.findViewById(resID);
              header.setTypeface(MyGlobalConfig.getInstance().getHeadersFont());
          }
  
          FragmentManager childFragMan = getChildFragmentManager();
          FragmentTransaction childFragTrans = childFragMan.beginTransaction();
          LastUpdatedFragment fragB = new LastUpdatedFragment();
          childFragTrans.add(R.id.FRAGMENT_PLACEHOLDER, fragB);
          childFragTrans.addToBackStack("B");
          childFragTrans.commit();        
  
  
          return rootView;
      }
  </code></pre>
  
  <p><strong>fragment_scoreboard.xml (simplified but displaying everything else)</strong></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/FRAGMENT_PLACEHOLDER"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical" &gt;
  
          &lt;LinearLayout
              style="@style/ListView"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:orientation="horizontal" &gt;
  
              &lt;TextView
                  android:id="@+id/f_scoreboard_header_tv0"
                  style="@style/ListViewRowHeader"
                  android:layout_width="0dp"
                  android:layout_height="wrap_content"
                  android:layout_weight="1"
                  android:text="#" /&gt;
  
          &lt;/LinearLayout&gt;
  
          &lt;ListView
              android:id="@+id/f_scoreboard_lvbody"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_centerHorizontal="true" &gt;
          &lt;/ListView&gt;
  
      &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>LastUpdatedFragment.java -> Child Fragment</strong></p>
  
  <pre><code>        public class LastUpdatedFragment extends Fragment{
          private View rootView;
          private TextView tv;
          private Context ctx;
  
          public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(
                      getActivity()));
              this.ctx = getActivity().getApplicationContext();
  
          }
  
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
                  Bundle savedInstanceState) {
  
              rootView = inflater.inflate(R.layout.fragment_date, container,
                      false);
              tv = (TextView) rootView.findViewById(R.id.f_date_tv);
              tv.setTypeface(MyGlobalConfig.getInstance().getBodyFont());
              tv.setText(getString(R.string.lastupdated) + ": " + Util.getLastUpdated(ctx));
              return rootView;
          }
      }
  </code></pre>
  
  <p><strong>fragment_date.xml</strong></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="match_parent"
          android:layout_height="wrap_content"
          android:orientation="horizontal" &gt;
  
          &lt;TextView
              android:id="@+id/f_date_tv"
              style="@style/LastUpdatedTV"
              android:layout_width="match_parent"
              android:text="Data de última actualização: 27/12/2014 21:30" /&gt;
      &lt;/LinearLayout&gt;
  </code></pre>