title: Android fragments overlapping after screen rotation
body: <p>This app is a learning exercise for me using fragments, among other things. It has a single activity that manages some different fragments. The first is a ListFragment (A), which shows when the app starts and loads list items from a cursor. Clicking a list item notifies the activity to replace the ListFragment with a DetailFragment (B) for that item. If while looking at (B) I rotate the screen, I see (B) on top of (A), like this:</p>
  
  <p><a href="https://i.stack.imgur.com/Tsfdw.png" rel="noreferrer">http://postimage.org/image/uhy016ds7/</a></p>
  
  <p>My best guess is it has to do with Android destroying and re-creating the activity on a configuration change. I am wondering what is the cleanest solution for this problem. Some code snippets follow, let me know if there's something else I should post. </p>
  
  <p><strong>res/layout/home.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/fragment_container"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" &gt;
  
      &lt;fragment
          android:id="@+id/fragment_place_list"
          android:name="com.simbiosys.apps.foodfast.ui.PlaceListFragment"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent" &gt;
      &lt;/fragment&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p><strong>MyActivity.onCreate</strong></p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.home);
  
      placeListFragment = (PlaceListFragment) getSupportFragmentManager().findFragmentById(
              R.id.fragment_place_list);
  
  }
  </code></pre>
  
  <p><strong>MyActivity.showDetailPane</strong></p>
  
  <pre><code>public void showDetailPane(String id, String reference) {
      placeDetailFragment = PlaceDetailFragment.newInstance(id, reference);
      FragmentManager fragmentManager = getSupportFragmentManager();
      FragmentTransaction ft = fragmentManager.beginTransaction();
      ft.addToBackStack(null);
      ft.hide(placeListFragment);
      ft.replace(R.id.fragment_container, placeDetailFragment);
      ft.show(placeDetailFragment);
      ft.commit();
  }
  </code></pre>