title: Replace the top fragment on the back stack
body: <p>I'm having so much trouble with Android fragments... Suppose my back stack looks like this</p>
  
  <pre><code>[C]
  [B]
  [A]
  ---
  </code></pre>
  
  <p>Pressing the back button would pop <code>Fragment C</code> off, and leaving <code>Fragment B</code> on the top of the stack. Now, how do I swap <code>Fragment C</code> for <code>Fragment D</code> while maintaining the back stack? Note, <code>Fragment B</code> cannot be seen during the operation.</p>
  
  <pre><code>[C] &lt;- [D]               [D]
  [B]            -----&gt;    [B]
  [A]                      [A]
  ---                      ---
  </code></pre>
  
  <p>This way, pressing the back button would pop <code>Fragment D</code> off, and leaving <code>Fragment B</code> on top. <code>Fragment C</code> is completely removed off the stack.</p>
  
  <p>I add each fragments to the stack like so</p>
  
  <pre><code>FragmentTransaction ft = manager.beginTransaction();
  ft.replace(id, instance, getTag(instance));
  ft.addToBackStack(getTag(instance));
  ft.commit();
  </code></pre>
  
  <p>I thought this could be achieved by doing the same calls without <code>addToBackStack</code>, but it just made <code>Fragment D</code> and <code>Fragment B</code> overlapped. </p>