标签:
在FragmentPagerAdapter中重写以下方法:
1 @Override 2 public Object instantiateItem(ViewGroup container, int position) { 3 Fragment fragment = (Fragment) super.instantiateItem(container, position); 4 fm.beginTransaction().show(fragment).commit(); 5 6 return fragment; 7 } 8 9 @Override 10 public void destroyItem(ViewGroup container, int position, Object object) { 11 Fragment fragment = (Fragment) object; 12 fm.beginTransaction().hide(fragment).commit(); 13 }
解决Fragment在Viepager中切换不保存状态的问题
标签:
原文地址:http://www.cnblogs.com/jinglecode/p/5096342.html