Android Error: "commit Already Called" When Remove A Fragment
I want to implement an activity that has a fragment! when I click on Fragment1 , Fragment2 is called , and when I click on Fragment2 , Fragment2 should be removed from the screen!
Solution 1:
Instead of reusing the passed-in transaction, create a new FragmentTransaction
instance that removes Fragment2.
Even easier is to add the first fragment transaction to fragment back stack (e.g. addToBackStack(null)
) and then in Fragment2, just pop the back stack with FragmentManager
popBackStack()
.
Solution 2:
Begin new transaction
fragTran = fragMan.beginTransaction();
fragTran.replace(R.id.frag_cont_two, fThree);
fragTran.addToBackStack(null);
fragTran.commit();
Solution 3:
I solved the issue
after calling commit()
and again replacing the fragment you should start from
fragmentTransaction = fragmentManager.beginTransaction();
Post a Comment for "Android Error: "commit Already Called" When Remove A Fragment"