我正在通过类似这样的片段填充视图寻呼机
I'm populating view pager through fragments likes this
pagerAdapter = new PagerAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.container);
for (int i = 0; i < 10; i++) {
newfragment fragobj = new newfragment();
fragobj.setArguments(bundle);
pagerAdapter.addFragment(fragobj, "Category");
}
mViewPager.setAdapter(pagerAdapter);
mViewPager.setCurrentItem(page);
我想清除所有碎片并在清除后添加新的碎片.如果我现在添加新片段,它会使用旧片段进行广告.
I want to clear all fragments and add new fragments after clearing. If I add new fragments now it ads on with old fragments.
我尝试了许多堆栈溢出答案,但没有一个对我有用.
I tried many stack overflow answers but none of them worked for me.
片段已经被移除和销毁.问题在于浏览量.
the fragment was already getting removed and destroyed. the issue was of viewpages.
只有这个对我有用
myViewPager.setSaveFromParentEnabled(false);
干杯!
这篇关于从 ViewPager 中删除或清除所有片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!