Back to project page book.
The source code is released under:
MIT License
If you think the Android project book listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package fragments; //from w ww . j ava2s .c o m import java.util.List; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.view.View; public class PageAdapter extends FragmentPagerAdapter { private List<Fragment> fragments; private FragmentManager fm; public PageAdapter(FragmentManager fm, List<Fragment> fragments) { super(fm); this.fm = fm; this.fragments = fragments; } public void remove(Fragment fragment){ if (this.fragments.contains(fragment)){ this.fragments.remove(fragment); } } public void addTo(int position, Fragment fragment){ this.fragments.add(position,fragment); } public void add(Fragment fragment){ this.fragments.add(fragment); } public int getPosition(Fragment fragment){ return this.fragments.indexOf(fragment); } @Override public Fragment getItem(int position) { return this.fragments.get(position); } @Override public int getCount() { return this.fragments.size(); } @Override public void destroyItem(View collection, int position, Object view) { ((ViewPager) collection).removeView((View) view); } }