title: How to set different content to tabs using ViewPager?
body: <p>Is there any way to set different content to tabs using <code>ViewPager</code>? I mean <strong>without creating fragments for every tab.</strong> </p>
  
  <p>So I have 1 fragment, which is applied to every tab. But the <strong>content of each should be different</strong>. And in my case all 3 tabs have same items.</p>
  
  <p>This is how I add tabs:</p>
  
  <pre><code>    @Override
  protected void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
  
      // Here we load the xml layout we created above
      setContentView(R.layout.activity_main);
  
      // Set up the action bar.
      final ActionBar actionBar = getSupportActionBar();
      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
  
      // Create the adapter that will return a fragment for each of the three
      // primary sections of the activity.
      mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
  
      // Set up the ViewPager with the sections adapter.
      mViewPager = (ViewPager) findViewById(R.id.pager);
      mViewPager.setAdapter(mSectionsPagerAdapter);
  
      // When swiping between different sections, select the corresponding
      // tab. We can also use ActionBar.Tab#select() to do this if we have
      // a reference to the Tab.
      mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener()
      {
          @Override
          public void onPageSelected(int position)
          {
              actionBar.setSelectedNavigationItem(position);
          }
      });
  
      // For each of the sections in the app, add a tab to the action bar.
  
  
      for (int i = 0; i &lt; mSectionsPagerAdapter.getCount(); i++)
      {
          // Create a tab with text corresponding to the page title defined by
          // the adapter. Also specify this Activity object, which implements
          // the TabListener interface, as the callback (listener) for when
          // this tab is selected.
  
          actionBar.addTab(
                  actionBar.newTab()
                          .setText(mSectionsPagerAdapter.getPageTitle(i))
                          .setTabListener(this));
      }
  </code></pre>
  
  <p>Every tab has this gridview layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;FrameLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
      &lt;GridView
      android:id="@+id/gridview"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:verticalSpacing="0dp"
      android:horizontalSpacing="0dp"
      android:stretchMode="columnWidth"
      android:numColumns="2" /&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>and I have an Adapter where items are added to this grid:</p>
  
  <pre><code>private class MyAdapter extends BaseAdapter
  {
      private List&lt;Item&gt; items = new ArrayList&lt;Item&gt;();
      private LayoutInflater inflater;
  
      public MyAdapter(Context context)
      {
          inflater = LayoutInflater.from(context);
  
          items.add(new Item("Item1", R.drawable.picture1));
          items.add(new Item("Item2", R.drawable.picture2));
      }
  
  private class Item
      {
          final String name;
          final int picId;
  
          Item(String name, int drawableId)
          {
              this.name = name;
              this.picId = drawableId;
          }
      }
  </code></pre>
  
  <p>and yeah, also there is <code>PlaceholderFragment</code> where this gridview is allocated:</p>
  
  <pre><code>public class PlaceholderFragment extends Fragment
  {
      public PlaceholderFragment() {}
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
      {
          View rootView = inflater.inflate(R.layout.fragment_main, container, false);
  
          // Here we inflate the layout we created above
          GridView gridView = (GridView) rootView.findViewById(R.id.gridview);
          gridView.setAdapter(new MyAdapter(MainActivity.this.getApplicationContext()));
          return rootView;
      }
  }
  </code></pre>