Skip to content Skip to sidebar Skip to footer

Replacing A Fragment From Inside A Fragment

I read online, that to call another fragment, to take up the FrameLayout, you need to create an interface that talks to the activity and when the button clicked the function inside

Solution 1:

Fragments are part of the Activity and fragment should be hosted through their parent activities as stated by google in Android developers docs. You can refer this link:- https://developer.android.com/training/basics/fragments/communicating

Solution 2:

You should call getFragmentManager().beginTransaction().replace(int id, Fragment fr).commit(); in onViewCreated() method, not onCreateView() method.

Just move your code in onCreateView() into onViewCreated() method.

Post a Comment for "Replacing A Fragment From Inside A Fragment"