解决方案:
1,viewPager.setOffscreenPageLimit(num);
2,Fragment的onCreatView()中:判断是否已经添加contentView
if (contentView != null) { ViewGroup parent = (ViewGroup) contentView.getParent(); if (parent != null) { parent.removeView(contentView); } return contentView; } else { contentView = inflater.inflate(R.layout.fragment_news, container, false); } return contentView;
3,FragmentPagerAdapter中重写destroyItem(),删除掉super.destroyItem()