Advertisement
Ankhwatcher

SectionsPagerAdapter

Nov 27th, 2013
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. public class SectionsPagerAdapter extends FragmentStatePagerAdapter {
  2.  
  3.         private FragmentManager fm;
  4.         private ArrayList<Fragment> fragments = new ArrayList<Fragment>();
  5.         private LoadingFragment loadingFragment = new LoadingFragment();
  6.  
  7.         public SectionsPagerAdapter(FragmentManager fm) {
  8.             super(fm);
  9.             fragments.add(loadingFragment);
  10.             this.fm = fm;
  11.  
  12.         }
  13.  
  14.         public void addFragment(Fragment fragment) {
  15.  
  16.  
  17.             fragments.add(fragment);
  18.             if (fragments.contains(loadingFragment))
  19.                 fragments.remove(loadingFragment);
  20.  
  21.             notifyDataSetChanged();
  22.         }
  23.  
  24.         @Override
  25.         public int getItemPosition(Object object) {
  26.             return POSITION_NONE;
  27.         }
  28.  
  29.         @Override
  30.         public Fragment getItem(int position) {
  31.             return fragments.get(position);
  32.         }
  33.  
  34.         @Override
  35.         public int getCount() {
  36.  
  37.             return fragments.size();
  38.         }
  39.  
  40.  
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement