title: Fragment Backstack Issue Content View Not Yet Created
body: <p>I'm receiving a content view not yet created error in the following situation:</p>
  
  <p>I have three fragments in one activity, fragment F1, listfragment F2, and fragment F3.</p>
  
  <p>When navigating from F1 to F2 F1 is added to the backstack.  When I navigate from F2 to F3 I do not add F2 to the backstack, so when I hit back I return to F1.  F2 to F1 and then F2 again works as expected.  F1 to F3 then back to F1 works fine, but if I try to navigate from F1 to F2 again I get a content view not yet created error.</p>
  
  <p>It seems the error is being caused by getlistview, but I'm calling getlistview from onactivity created, which should be called after the view is created so I'm not sure where the error is coming from.</p>
  
  <p>Thanks for any help anyone can offer!</p>
  
  <p>EDIT code attached</p>
  
  <p>Logcat:</p>
  
  <p>08-19 01:11:13.787: E/AndroidRuntime(1289): FATAL EXCEPTION: main
  08-19 01:11:13.787: E/AndroidRuntime(1289): java.lang.IllegalStateException: Content view not yet created
  08-19 01:11:13.787: E/AndroidRuntime(1289):     at android.support.v4.app.ListFragment.ensureList(ListFragment.java:328)
  08-19 01:11:13.787: E/AndroidRuntime(1289):     at android.support.v4.app.ListFragment.getListView(ListFragment.java:222)
  08-19 01:11:13.787: E/AndroidRuntime(1289):     at com.alex.hours.RestaurantListFragment$6.done(RestaurantListFragment.java:418)
  08-19 01:11:13.787: E/AndroidRuntime(1289):     at com.parse.FindCallback.internalDone(FindCallback.java:45)
  08-19 01:11:13.787: E/AndroidRuntime(1289):     at com.parse.FindCallback.internalDone(FindCallback.java:31)
  08-19 01:11:13.787: E/AndroidRuntime(1289):     at com.parse.Parse$5$1.run(Parse.java:891)
  08-19 01:11:13.787: E/AndroidRuntime(1289):     at android.os.Handler.handleCallback(Handler.java:730)
  08-19 01:11:13.787: E/AndroidRuntime(1289):     at android.os.Handler.dispatchMessage(Handler.java:92)
  08-19 01:11:13.787: E/AndroidRuntime(1289):     at android.os.Looper.loop(Looper.java:137)
  08-19 01:11:13.787: E/AndroidRuntime(1289):     at android.app.ActivityThread.main(ActivityThread.java:5103)
  08-19 01:11:13.787: E/AndroidRuntime(1289):     at java.lang.reflect.Method.invokeNative(Native Method)
  08-19 01:11:13.787: E/AndroidRuntime(1289):     at java.lang.reflect.Method.invoke(Method.java:525)
  08-19 01:11:13.787: E/AndroidRuntime(1289):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
  08-19 01:11:13.787: E/AndroidRuntime(1289):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  08-19 01:11:13.787: E/AndroidRuntime(1289):     at dalvik.system.NativeStart.main(Native Method)</p>
  
  <p>Relevant code:</p>
  
  <p>Creating F1 fragment from navigation drawer:</p>
  
  <pre><code>    private void selectItem(int position) {
      // update the main content by replacing fragments
      FragmentManager fragmentManager;
      Bundle args = new Bundle();
      Log.i("POSITION", "position: " + position);
      switch (position) {
      case 0:
          MainActivityFragment mainActivity = new MainActivityFragment();
          fragmentManager = getSupportFragmentManager();
          fragmentManager.popBackStack();
          fragmentManager.beginTransaction()
                  .replace(R.id.content_frame, mainActivity)
                  .commit();
          break;
      case 1:
  
          args.putString(RestaurantListFragment.QUERY_CODE,
                  RestaurantListFragment.ALL_RESTAURATNS);
          RestaurantListFragment myRestaurants = new RestaurantListFragment();
          myRestaurants.setArguments(args);
          fragmentManager = getSupportFragmentManager();
          if(fragmentManager.getBackStackEntryCount()&gt;0){
              fragmentManager.popBackStack();
          }
          fragmentManager.beginTransaction()
                  .replace(R.id.content_frame, myRestaurants)
                  .addToBackStack(null).commit();
          break;
      }
  </code></pre>
  
  <p>Creating F2 fragment:</p>
  
  <pre><code>        args.putString(RestaurantListFragment.QUERY_CODE, RestaurantListFragment.ALL_RESTAURATNS);
          RestaurantListFragment allRestaurants = new RestaurantListFragment();
          allRestaurants.setArguments(args);
          fragmentManager = getFragmentManager();
          fragmentManager.beginTransaction()
                  .replace(R.id.content_frame, allRestaurants)
                  .addToBackStack(null).commit();
  </code></pre>
  
  <p>Creating F3 from a click in listview</p>
  
  <pre><code>public void onListItemClick(ListView l, View v, int position, long id) {
      Restaurant r = ((RestaurantAdapter) getListAdapter()).getItem(position);
      Bundle args = new Bundle();
      if (getArguments() != null) {
          String queryCode = getArguments().getString(QUERY_CODE);
          args.putString(QUERY_CODE, queryCode);
  
      }
  
      args.putString(RestaurantFragment.EXTRA_RESTAURANT_ID, r.getObjectId());
      RestaurantFragment restaurantFragment = new RestaurantFragment();
      restaurantFragment.setArguments(args);
      FragmentManager fragmentManager = getFragmentManager();
  
      fragmentManager.beginTransaction()
              .replace(R.id.content_frame, restaurantFragment)
              .addToBackStack(null).commit();
  </code></pre>
  
  <p>Code that throws the error:</p>
  
  <pre><code>if (getListView().getAdapter() == null) {
                              RestaurantAdapter adapter = new RestaurantAdapter(
                                      getListView().getContext(),
                                      mRestaurants);
                              setListAdapter(adapter);
  </code></pre>