You are doing two things wrong here:
-
You cannot replace a fragment that is statically placed in an
xmllayout file. You should create a container (e.g. aFrameLayout) in the layout and then add the fragment programatically usingFragmentTransaction. -
FragmentTransaction.replaceexpects the id of the container that contains the fragment and not the id of the fragment as the first parameter. So you should pass the first argument as the id of the container that you added the first fragment to.
You can refer to this link for more details.