title: Best practice for nested fragments in Android 4.0, 4.1 (<4.2) without using the support library
body: <p>I'm writing an app for 4.0 and 4.1 tablets, for which <strong>I do not want to use the support libraries</strong> (if not needed) but the 4.x api only therefore.</p>
  
  <p>So my target platform is very well defined as: >= 4.0 and &lt;= 4.1</p>
  
  <p>The app has a multi-pane layout (two fragments, one small on the left, one content fragment on the right) and an action bar with tabs.</p>
  
  <p>Similar to this:</p>
  
  <p><img src="https://i.stack.imgur.com/Ml3hl.png" alt="enter image description here"></p>
  
  <p>Clicking a tab on the action bar changes the 'outer' fragment, and the inner fragment then is a fragment with two nested fragments (1. small left list fragment, 2. wide content fragment).</p>
  
  <p>I am now wondering what's the best practice to replace fragments and especially nested fragments. 
  The ViewPager is part of the support library, there's no native 4.x alternative for this class. Appear to be 'deprecated' in my sense.
   - <a href="http://developer.android.com/reference/android/support/v4/view/ViewPager.html" rel="noreferrer">http://developer.android.com/reference/android/support/v4/view/ViewPager.html</a></p>
  
  <p>Then I read the release notes for Android 4.2, regarding <code>ChildFragmentManager</code>, which would be a good fit, but I am targeting 4.0 and 4.1, so this can't be used either.</p>
  
  <p><code>ChildFragmentManager</code> is only available in 4.2</p>
  
  <ul>
  <li><a href="http://developer.android.com/about/versions/android-4.2.html#NestedFragments" rel="noreferrer">http://developer.android.com/about/versions/android-4.2.html#NestedFragments</a></li>
  <li><a href="http://developer.android.com/reference/android/app/Fragment.html#getChildFragmentManager()" rel="noreferrer">http://developer.android.com/reference/android/app/Fragment.html#getChildFragmentManager()</a></li>
  </ul>
  
  <p>Unfortunately, there are hardly any good examples out there that show best practices for fragments usages without the support library, even in the entire Android developer guides; and especially nothing regarding nested fragments.</p>
  
  <p><strong>So I am wondering: is it simply not possible to write 4.1 apps with nested fragments without using the support library and everything that comes with it? (need to use FragmentActivity instead of Fragment, etc.?)</strong>
  Or what would be the best practice?</p>
  
  <hr>
  
  <p>The problem that I am currently having in the development is exactly this statement:</p>
  
  <ul>
  <li><a href="http://developer.android.com/about/versions/android-4.2.html#NestedFragments" rel="noreferrer">http://developer.android.com/about/versions/android-4.2.html#NestedFragments</a></li>
  </ul>
  
  <blockquote>
    <p>The Android Support Library also now supports nested fragments, so you
    can implement nested fragment designs on Android 1.6 and higher.</p>
    
    <p>Note: You cannot inflate a layout into a fragment when that layout
    includes a <code>&lt;fragment&gt;</code>. Nested fragments are only supported when added
    to a fragment dynamically.</p>
  </blockquote>
  
  <p>Because I put define the nested fragments in XML, which apparently causes an error like:</p>
  
  <pre><code>Caused by: java.lang.IllegalArgumentException: Binary XML file line #15: Duplicate id 0x7f090009, tag frgCustomerList, or parent id 0x7f090008 with another fragment for de.xyz.is.android.fragment.CustomerListFragment_
  </code></pre>
  
  <p>At the moment, I conclude for myself: even on 4.1, when I don't even want to target the 2.x platform, nested fragments as shown in the screenshot are not possible without the support library.</p>
  
  <p>(This might actually be more of a wiki entry than a question, but maybe somebody else has managed it before).</p>
  
  <p><strong>Update:</strong></p>
  
  <p>A helpful answer is at: <a href="https://stackoverflow.com/questions/6672066/fragment-inside-fragment/6672688#6672688">Fragment Inside Fragment</a></p>