0

I have a PagerAdapter with a dynamic number of elements. You can modify the number of tabs with a single call, which clears the list and the count to 0. Unfortunately, this does not remove the fragment that is currently showing.

public class MyPagerAdapter extends FragmentStatePagerAdapter {

    private List<Pojo> pojos = new ArrayList<>;

    @Override
    public int getCount() {
        return pojos.size();
    }  

    public void removeAll() {
        this.pojos.clear();
        notifyDataSetChanged();
    }
}

Does anyone know how to force the ViewPager to clear himself?

UPDATE 1:

If you use viewPager.removeAllViews() then the viewPager is unusable afterwards even after adapter notifies new data changes.

MLProgrammer-CiM
  • 17,231
  • 5
  • 42
  • 75

0 Answers0