Code example for FragmentStatePagerAdapter

Methods: setPrimaryItem

0
         return selectedFragment;
      } 
 
      @Override 
      public void setPrimaryItem(ViewGroup container, int position, Object object) {
         super.setPrimaryItem(container, position, object);
         mSelectedTab = position;
      } 
 
      public String getFragmentScreenLabel(int key) {
         return mPageLabelMap.get(key);
      } 
 
      @Override 
      public void destroyItem(View container, int position, Object object) {
         super.destroyItem(container, position, object);
 
         mPageLabelMap.remove(position);
      } 
   } 
}