content: package com.common.comm;
  
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentManager;
  import android.support.v4.app.FragmentPagerAdapter;
  
  import java.util.ArrayList;
  import java.util.List;
  
  /**
   * author miekoz on 2016/3/21.
   * email  meikoz@126.com
   */
  public class MainFragmentPagerAdapter extends FragmentPagerAdapter {
      private final List<Fragment> mFragments = new ArrayList<>();
      private final List<String> mFragmentTitles = new ArrayList<>();
  
      public MainFragmentPagerAdapter(FragmentManager fm) {
          super(fm);
      }
  
      public void MainFragmentPagerAdapter(Fragment fragment, String title) {
          mFragments.add(fragment);
          mFragmentTitles.add(title);
      }
  
      public void addFragment(Fragment fragment, String title) {
          mFragments.add(fragment);
          mFragmentTitles.add(title);
      }
  
      @Override
      public Fragment getItem(int position) {
          return mFragments.get(position);
      }
  
      @Override
      public int getCount() {
          return mFragments.size();
      }
  
      @Override
      public CharSequence getPageTitle(int position) {
          return mFragmentTitles.get(position);
      }
  }
  