Skip to content

Instantly share code, notes, and snippets.

@Reacoder
Created July 31, 2014 09:43
Show Gist options
  • Save Reacoder/973542b8c09e9c86b02f to your computer and use it in GitHub Desktop.
Save Reacoder/973542b8c09e9c86b02f to your computer and use it in GitHub Desktop.
/* 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