android Programming Glossary: preinitializedfragment
Switching fragments within tab http://stackoverflow.com/questions/10502786/switching-fragments-within-tab Tab tab FragmentTransaction ft SherlockFragment preInitializedFragment SherlockFragment mActivity.getSupportFragmentManager .findFragmentByTag.. if the fragment is already initialized if mFragment null preInitializedFragment null If not instantiate and add it to the activity mFragment.. attach it in order to show it ft.attach mFragment else if preInitializedFragment null ft.attach preInitializedFragment mFragment preInitializedFragment..
Switching fragments within tab http://stackoverflow.com/questions/10502786/switching-fragments-within-tab each of the ActionBar.TabListener callbacks public void onTabSelected Tab tab FragmentTransaction ft SherlockFragment preInitializedFragment SherlockFragment mActivity.getSupportFragmentManager .findFragmentByTag mTag Check if the fragment is already initialized.. .findFragmentByTag mTag Check if the fragment is already initialized if mFragment null preInitializedFragment null If not instantiate and add it to the activity mFragment SherlockFragment SherlockFragment.instantiate mActivity mClass.getName.. mFragment mTag else if mFragment null If it exists simply attach it in order to show it ft.attach mFragment else if preInitializedFragment null ft.attach preInitializedFragment mFragment preInitializedFragment public void onTabUnselected Tab tab FragmentTransaction..
|