Avoid recreating same view when perform tab switching

后端 未结 6 588
一生所求
一生所求 2021-01-30 17:43

Current, I have 2 Fragments, which is switch-able through ActionBar\'s tab.

    getSupportActionBar().setNavigationMode(ActionBar.NAVIG         


        
6条回答
  •  醉梦人生
    2021-01-30 17:50

    View mMyView = null;     
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state)  {
             if (state == null) {
                 mMyView = new MyView(getActivity());
             } else {
                 container.removeView(mMyView);
             }
    
             return mMyView; 
        }
    

提交回复
热议问题