I'm trying to switch layout from full view to double pane view like following:
....... .......
. . . .
. . --> .......
. . . .
....... .......
Now the issue is I'm going from 1 container with fragment to 2 containers with a fragment in each. In order to do this I'm removing the old fragment and adding the new ones. BUT when I remove the fragment in the large one an OLD fragment appears instead. I've set tag on the old fragment and I search after it with getFragmentManager().findFragmentByTag()
but it simply returns null.
For now my hack is use largeView.setVisibility(View.gone); is there a better way to handle this?
Edit:
It seems like the bug isn't reproduced any longer. That means replace does what it should have done all along. But WHY did it glitch? Eclipse? Android?
Edit2
This is how I replace fragments:
Fragment fragment = new SimpleScannerFragment();
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.main_container, fragment, SCAN_FRAGMENT_TAG);
ft.commit();
Before switching to double pane layout I pop back stack like this:
getFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
I remove fragments using this:
removeFragment = getFragmentManager().findFragmentByTag(SCAN_FRAGMENT_TAG);
if(removeFragment != null) {
getFragmentManager().beginTransaction().remove(removeFragment).commit();
}
I'm switching views visiblity when I go from single to double pane:
// hide main layout as well, THIS IS MY HACKS just in case it does this again...
FrameLayout frame = (FrameLayout) this.findViewById(R.id.main_container);
frame.setVisibility(View.GONE);
// add new layout
FragmentTransaction ft = getFragmentManager().beginTransaction();
CustomMapFragment fragment = CustomMapFragment.newInstance();
ScoreFragment scoreFragment = new ScoreFragment();
ft.replace(R.id.main_narrow_bot_container, fragment);
ft.replace(R.id.main_narrow_top_container, scoreFragment);
ft.commit();