title: Adding titles to ViewPager
body: <p>I have set up a ViewPager for swipeable tabs and now I want to add titles at the top of the page to indicate what fragment is being shown.</p>
  
  <p>This is the code so far:</p>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical" &gt;
  
      &lt;android.support.v4.view.ViewPager
          android:id="@+android:id/viewpager"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>public class MainActivity extends FragmentActivity {
  
      private PagerAdapter mPagerAdapter;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          super.setContentView(R.layout.activity_main);
  
          this.initialisePaging();
      }
  
      private void initialisePaging() {
  
          List&lt;Fragment&gt; fragments = new Vector&lt;Fragment&gt;();
  
          // Add fragments here
          fragments.add(Fragment.instantiate(this, PickerFragment.class.getName()));
          fragments.add(Fragment.instantiate(this, DisplayFragment.class.getName()));
  
          this.mPagerAdapter  = new PageAdapter(super.getSupportFragmentManager(), fragments);
          ViewPager pager = (ViewPager)super.findViewById(R.id.viewpager);
          pager.setAdapter(this.mPagerAdapter);
      }
  
  }
  </code></pre>
  
  <p><strong>PageAdapter.java</strong></p>
  
  <pre><code>public class PageAdapter extends FragmentPagerAdapter {
  
      private List&lt;Fragment&gt; fragments;
  
      public PageAdapter(FragmentManager fm, List&lt;Fragment&gt; fragments) {
          super(fm);
          this.fragments = fragments;
      }
  
      @Override
      public Fragment getItem(int position) {
          return this.fragments.get(position);
      }
  
      @Override
      public int getCount() {
          return this.fragments.size();
      }
  }
  </code></pre>
  
  <p>This works and I am able to swipe between the two tabs but there are no titles.</p>
  
  <p>I want to end up with something that looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/feWcv.png" alt="Google play"></p>
  
  <p>I would appreciate any help on how I could set this up.</p>