title: RecyclerView in FragmentPagerAdaper only updates when screen is rotated
body: <p>I have a fragment in a FragmentPagerAdpater. The Fragment is basically a RecyclerView. The source for the RecyclerView is provided by a Loader which is inside the Fragment.</p>
  
  <p>My problem is that the list appears empty when it is first instantiated. But when I rotate the screen, it appears fine. </p>
  
  <p>Do you have any idea what could go wrong?
  I am happy to provide some (or a lot) of code if needed. Just tell me which parts you want to see. </p>
  
  <p>Here is the code from the parent activity:</p>
  
  <pre><code>public class MyFragmentPagerAdapter extends FragmentPagerAdapter {
  
      public MyFragmentPagerAdapter(FragmentManager fm) {
          super(fm);
      }
  
      @Override
      public Fragment getItem(int i) {
          switch (i) {
              case 0:
                  //We return an instance of the RouteListFragment
                  RouteListFragment frag = RouteListFragment.getInstance(session.getId());
                  return frag;
              case 1:
                  //We return an instance of the RouteSpotListFragment
                  RouteSpotListFragment frag2 = RouteSpotListFragment.getInstance(sessionSpot.getId());
                  return frag2;
              default :
                  return null;
          }
  
      }
  </code></pre>
  
  <p>The main methods from the Fragment:</p>
  
  <pre><code>public static RouteListFragment getInstance (int sessionId){
      RouteListFragment frag = new RouteListFragment();
      Bundle bundle = new Bundle ();
      bundle.putInt(SESSION_ID, sessionId);
      frag.setArguments(bundle);
      return frag;
  }
  
  /* (non-Javadoc)
   * @see android.app.Fragment#onCreate(android.os.Bundle)
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      //We extract the RouteList from the Bundle
      Bundle bundle = getArguments();
      sessionId = bundle.getInt(SESSION_ID);
  
      //We create a MyRouteListAdapter with a null cursor
      Cursor cursor = null;
      routeListAdapter = new MyRouteListAdapter(cursor, getActivity());
      updateList();
  
      super.onCreate(savedInstanceState);
  }
  
  /* (non-Javadoc)
   * @see android.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
   */
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
      //Inflate the layout
      layout = (RelativeLayout) inflater.inflate(R.layout.fragment_route_list, container, false);
  
      routeSource = new RouteDataSource (getActivity());
  
      //Now that we have the routeSource, we can prepare the routeListAdapter
      routeRecyclerList = (RecyclerView) layout.findViewById(R.id.route_list_view);
       // use a linear layout manager
      mLayoutManager = new LinearLayoutManager(getActivity());
      routeRecyclerList.setLayoutManager(mLayoutManager);
  
      routeRecyclerList.setAdapter(routeListAdapter);
  
      return layout;
  }
  
      public void updateList(){
      /*
       * we get the loaderManager to start the query
       * If a Loader has already been initiated, we need to reload it. Otherwise the 
       * onCreateLoader callback method will not be called
       * Else, we initiate a Loader
       */
      LoaderManager manager = getLoaderManager();
      if (manager.getLoader(LOADER_GET_ALL_ROUTES)!= null)    
          manager.restartLoader(LOADER_GET_ALL_ROUTES, null, this);
      else manager.initLoader(LOADER_GET_ALL_ROUTES, null, this);
  
  }
  </code></pre>
  
  <p>Finally, I swap the cursor in the onLoadFinished() callback method as part of the LoaderManager.Callback methods.</p>
  
  <p><strong>EDIT</strong>: I just realized that if I wait for the LoaderManager to finish loading (1-2 seconds), before swiping the the Fragment which holds the Loader, the content is displayed.</p>
  
  <p>I don't know if that new info changes anything. I am still very much stuck and definitely need help.</p>