title: Recyclerviews in ViewPager
body: <p>I'm trying to get this working: I basically want two Recyclerviews in one ViewPager. I followed this Tutorial: <a href="http://android-java-development.blogspot.de/2012/05/system.html" rel="noreferrer">http://android-java-development.blogspot.de/2012/05/system.html</a>, but it doesn't seem to work. I looks like the view pager is empty and the recycler view doesn't show up.</p>
  
  <p>Here's my layout code:</p>
  
  <pre><code>&lt;android.support.v4.widget.SwipeRefreshLayout
          android:id="@+id/pager_refresh_layout"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:paddingTop="@dimen/tab_height"&gt;
  
          &lt;android.support.v4.view.ViewPager
              android:id="@+id/pager"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="@color/accent"/&gt;
      &lt;/android.support.v4.widget.SwipeRefreshLayout&gt;
  </code></pre>
  
  <p>And my PageAdapter:</p>
  
  <pre><code>public class NewsPagerAdapter extends PagerAdapter {
      private Context context;
      private Vector&lt;RecyclerView&gt; recyclerViewList;
      private String[] titles;
  
      public NewsPagerAdapter(Context context, int titlesId) {
          this.context = context;
          this.recyclerViewList = new Vector&lt;&gt;();
  
          setTitles(titlesId);
      }
  
      public void add(RecyclerView recyclerView) {
          recyclerViewList.add(recyclerView);
      }
  
      public RecyclerView.Adapter getAdapterForViewAtIndex(int index) {
          return recyclerViewList.get(index).getAdapter();
      }
  
      @Override
      public Object instantiateItem(ViewGroup container, int position) {
          container.addView(recyclerViewList.get(position),
                  new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100)
          );
          return container;
      }
  
      @Override
      public int getCount() {
          return recyclerViewList.size();
      }
  
      @Override
      public boolean isViewFromObject(View view, Object object) {
          return view.equals(object);
      }
  
      @Override
      public void destroyItem(ViewGroup container, int position, Object object) {
          container.removeView((View) object);
      }
  
      @Override
      public CharSequence getPageTitle(int position) {
          return titles[position];
      }
  
      public void setTitles(int titles) {
          this.titles = context.getResources().getStringArray(titles);
      }
  }
  </code></pre>
  
  <p>And my onCreatView method:</p>
  
  <pre><code>GridLayoutManager layoutManager1 = new GridLayoutManager(getActivity(), getResources().getInteger(R.integer.news_column_count));
  
  GridLayoutManager layoutManager2 = new GridLayoutManager(getActivity(), getResources().getInteger(R.integer.news_column_count));
  
  RecyclerView listView1 = new RecyclerView(getActivity());
  RecyclerView listView2 = new RecyclerView(getActivity());
  listView1.setLayoutManager(layoutManager1);
  listView2.setLayoutManager(layoutManager2);
  
  NewsAdapter adapter1 = new NewsAdapter(getActivity(), null);
  NewsAdapter adapter2 = new NewsAdapter(getActivity(), null);
  adapter1.setOnItemClickListener(this);
  adapter2.setOnItemClickListener(this);
  
  listView1.setAdapter(adapter1);
  listView2.setAdapter(adapter2);
  
  newsPagerAdapter.add(listView1);
  newsPagerAdapter.add(listView2);
  
  newsViewPager.setAdapter(newsPagerAdapter);
  </code></pre>
  
  <p>Here I'm passing the cursor object to the adapter:</p>
  
  <pre><code>@Override
      public void onLoadFinished(Loader&lt;Cursor&gt; loader, Cursor data) {
          ((NewsAdapter) newsPagerAdapter.getAdapterForViewAtIndex(0)).swapCursor(data);
      }
  </code></pre>