I have an application that consists of using ActionBarSherlock in tab mode.I have 5 tabs and the content of each tab is handled using fragments. For tab2 though, I have a fr
I know this is an old post, but the suggested answers didn't work on my end. I want to leave this here just in case someone will find it useful.
What i did is:
@Override
public void onResume() {
super.onResume();
// add all fragments
FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
for(Fragment fragment : fragmentPages){
String tag = fragment.getClass().getSimpleName();
fragmentTransaction.add(R.id.contentPanel, fragment, tag);
if(fragmentPages.indexOf(fragment) != currentPosition){
fragmentTransaction.hide(fragment);
} else {
lastTag = tag;
}
}
fragmentTransaction.commit();
}
Then in:
@Override
public void onPause() {
super.onPause();
// remove all attached fragments
for(Fragment fragment: fragmentPages){
getChildFragmentManager().beginTransaction().remove(fragment).commit();
}
}