title: Android multiple fragment transaction ordering
body: <p>I have a <code>HorizontalScrollView</code> containing a (horizontal) <code>LinearLayout</code> which I use as the container for adding multiple fragments. Upon some changes, I need to remove all fragments from that container and add new ones. However, there seems to be a problem with ordering when I'm removing the old fragments.</p>
  
  <p>Here are the scenarios:</p>
  
  <ul>
  <li>app startup
  <ul>
  <li>correctly adding fragments <code>A1</code>,<code>B1</code>,<code>C1</code>,<code>D1</code> in this order</li>
  </ul></li>
  <li>change content
  <ul>
  <li>if not removing initial fragments, but adding <code>A2</code>,<code>B2</code>,<code>C2</code> (as a single transaction), it will show <code>A1</code>,<code>B1</code>,<code>C1</code>,<code>D1</code>,<code>A2</code>,<code>B2</code>,<code>C2</code></li>
  <li>if removing initial fragments (either as a separate or using the same transaction), then adding <code>A2</code>,<code>B2</code>,<code>C2</code>, it will show <code>C2</code>,<code>B2</code>,<code>A2</code></li>
  </ul></li>
  </ul>
  
  <p>For now I found a workaround, where I'm adding the new fragments first then removing the old ones (still as part of the same transaction) and that is working properly.</p>
  
  <p><strong>EDIT:</strong>  The workaround doesn't work all the time.</p>
  
  <p>I'm using <code>android.support.v4.app.Fragment</code>. </p>
  
  <p>Any ideas on what's happening? </p>