Can't change container ID of fragment BodyPartFragment
When trying to launch the solution for the exercise DisplayThreeFragments app crashes with the error: Caused by: java.lang.IllegalStateException: Can't change container ID of fragment BodyPartFragment{302569e id=0x7f0b0058}: was 2131427416 now 2131427417 on the emulator Nexus 5 API 24
However, if I add fragmentManager.executePendingTransactions() after each transaction - it works.
same
You probably created only one instance of BodyPartFragment and then trying to update its fields value which causes the error.Create a new fragment object for each transaction.
Why can't we use same fragment object and place it in three separate Framelayout? I would like to know why this happens.