Android platform: 3.1
I am trying to move a fragment from a container A to a container B. Here follows the code to accomplish this:
private void rea
I found the problem was I needed two FragmentTransactions. I was trying to remove() and commit() twice on the same one.
// create new fragment
MyFragment myNewFragment = MyFragment.newInstance(this, data, true);
FragmentManager fm = this.getSupportFragmentManager();
// clear the back stack
fm.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
//fragmentTransaction is created for the removal of the old
FragmentTransaction fragmentTransaction = fm.beginTransaction();
fragmentTransaction.remove(myOldFragment);
fragmentTransaction.commit();
fm.executePendingTransactions();
// fragmentTransaction2 is created to add the new one
FragmentTransaction fragmentTransaction2 = fm.beginTransaction();
fragmentTransaction2.add(R.id.fragment_frame, myNewFragment);
fragmentTransaction2.commit();
fm.executePendingTransactions();