Problem is your trying to add the Fragment B
as a Child Fragment of Fragment A
in R.id.frame_container
, and I suspect the frame_container
is not a view in Fragment A layout(R.layout.fragment_home).
You can always add a child fragment using getChildFragmentManager(), but it needs a container to hold the fragment.
In your case , I don't see any need of adding the Fragment B as a child for Fragment A.
You need to replace the Fragment A attached in Activity with Fragment B using the the Activity Fragment Manager
Change the line in Button
onClick()
FragmentTransaction ft = getChildFragmentManager().beginTransaction();
as
FragmentTransaction ft = getActivity().getFragmentManager().beginTransaction();