标签:des style blog http color 使用 strong 2014
1 -->onPause 2 -->onStop 3 -->onDestroyView
1 -->onCreateView 2 -->onStart 3 -->onResume
可见,界面3对应的Fragment被销毁并重新创建。
mPager .setOffscreenPageLimit(2);
参数:int limit - 缓存当前界面每一侧的界面数
1 @Override 2 public void onDestroyView() { 3 LogUtils.d(TAG , "-->onDestroyView"); 4 super .onDestroyView(); 5 if (null != FragmentView) { 6 ((ViewGroup) mFragmentView.getParent()).removeView(mFragmentView); 7 } 8 }
步骤2:在onCreateView方法内复用RootView1 @Override 2 public View onCreateView(LayoutInflater inflater, ViewGroup container, 3 Bundle savedInstanceState) { 4 LogUtils.d (TAG, "-->onCreateView"); 5 if (null == mFragmentView) { 6 mFragmentView = inflater.inflate(R.layout.fragment, container, false); 7 mListView = (ListView) mFragmentView .findViewById(R.id.mm_listview); 8 mListView.setAdapter(mAdapter); 9 mPbar = (ProgressBar) mFragmentView.findViewById(R.id.pbar_mm_loading); 10 mPbar.setVisibility(View.VISIBLE); 11 } 12 13 return mFragmentView ; 14 }
【原创】【ViewPager+Fragment】ViewPager中切换界面Fragment被销毁的问题分析,布布扣,bubuko.com
【原创】【ViewPager+Fragment】ViewPager中切换界面Fragment被销毁的问题分析
标签:des style blog http color 使用 strong 2014
原文地址:http://www.cnblogs.com/monodin/p/3866441.html