title: How can I put titles in ViewPager using fragments?
body: <p>I am using ViewPager to allow user to swipe between fragments.</p>
  
  <p>How can I add a the title of each fragment to the screen?</p>
  
  <pre><code>package com.multi.andres;
  
  import java.util.List;
  import java.util.Vector;
  
  import com.viewpagerindicator.TitlePageIndicator;
  import com.viewpagerindicator.TitleProvider;
  
  import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentActivity;
  import android.support.v4.app.FragmentManager;
  import android.support.v4.app.FragmentPagerAdapter;
  import android.support.v4.view.ViewPager;
  
  public class ViewPagerFragment extends FragmentActivity{
  
      private PagerAdapter mPagerAdapter; //contiene el pager adapter
      private static String[] titulosPaginas = { "APP 1", "APP 2" };
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          super.setContentView(R.layout.lcmeter); //layout que contiene el ViewPager
  
          initialisePaging(); //inicializo las paginas
      }
  
      private void initialisePaging() {
  
          List&lt;Fragment&gt; fragments = new Vector&lt;Fragment&gt;();
          fragments.add(Fragment.instantiate(this, FragmentPrueba1.class.getName()));
          fragments.add(Fragment.instantiate(this, FragmentPrueba2.class.getName()));
          this.mPagerAdapter  = new PagerAdapter(super.getSupportFragmentManager(), fragments);
  
          ViewPager pager = (ViewPager)super.findViewById(R.id.pager);
          pager.setAdapter(this.mPagerAdapter);
  
          //Agrega los titulos
          TitlePageIndicator titleIndicator = (TitlePageIndicator) findViewById(R.id.titulos);    //layout XML
          titleIndicator.setViewPager(pager);
      }
  
      /** *************************************************************************************************
      /** Clase:   public class PagerAdapter extends FragmentPagerAdapter implements TitleProvider
      /** Notas:   extends FragmentPagerAdapter permite el uso de las paginas de ViewPager pero con Fragments
      /**          implements TitleProvider permite el uso de los titulos en las paginas
      /** Funcion: crea paginas por las cuales deslizarse horizontalmente las cuales son usadas
      ****************************************************************************************************/
      public class PagerAdapter extends FragmentPagerAdapter implements TitleProvider {
  
          private List&lt;Fragment&gt; fragments;
  
          public String getTitle(int position) {
              // TODO Auto-generated method stub
              return titulosPaginas[position];    // titulo de la pagina
          }
  
          public PagerAdapter(FragmentManager fm, List&lt;Fragment&gt; fragments) {
              super(fm);
              this.fragments = fragments;
          }
  
          @Override
          public int getCount() {
              return this.fragments.size();
          }
  
          @Override
          public Fragment getItem(int position) {
              return this.fragments.get(position);
          }
  
      }
  
  }
  </code></pre>
  
  <p>But it doesn't show the titles of ViewPager and I don't know why. I used ViewPager with titles before but not with fragments and I cannot get titles working now.</p>