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

The article was published on May 20, 2017 @ 1:58 PM

Leave a Comment