Created
July 31, 2014 09:43
-
-
Save Reacoder/973542b8c09e9c86b02f to your computer and use it in GitHub Desktop.
From http://stackoverflow.com/questions/12783571/android-viewpager-change-adapter android viewpager change adapter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Clear all Fragments inside current adapter */ | |
public class MyPagerAdapter extends FragmentPagerAdapter | |
{ | |
private ArrayList<Fragment> fragments=new ArrayList<Fragment>(); | |
//...some stuff | |
public void clearAll() //Clear all page | |
{ | |
for(int i=0; i<fragments.size(); i++) | |
fragMan.beginTransaction().remove(fragments.get(i)).commit(); | |
fragments.clear(); | |
} | |
} | |
/* Set current adapter to null */ | |
Constants.VP.removeAllViews(); | |
Constants.VP.setAdapter(null); | |
/* Assign new adpater for ViewPager */ | |
Constants.PAGER=new MyewPagerAdapter(getSupportFragmentManager()); | |
Constants.VP.setAdapter(Constants.PAGER); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment