In this tutorial, you will learn how to replace fragments in the FrameLayout layout in Android.

You should always add, remove, and replace your fragments problematically. As such I suggest you replace your “TitleFragment” fragments with containers such as FrameLayout. I had to use android.support.v4.app.Fragment; instead of android.app.Fragment;. This is the code I got it to work with:

setFragment method called from displayView method,
And to set it (from the navbar onNavigationItemSelected(), you do this:
Replace fragments in FrameLayout layout

Leave a Comment