Home Open a fragment from another fragment always keeps the previous fragment title
Reply: 1

Open a fragment from another fragment always keeps the previous fragment title

mvasco Published in 2018-01-13 01:15:44Z

I am working on an Android app that has only one Activity and 8 Fragments. MainActivity has a DrawerLayout with a menu that opens each of the fragments.

Sometimes I need to navigate from one fragment to another directly, I mean, after executing some methods on a fragment, I need to open one of the other fragments.

For example, the user opens fragment B from the side menu, then the users executes some methods on fragment B, and after execution, fragment C should be open.

It works fine, my only issue is that fragment C keeps the fragment title from fragment B, and I need to show the original title from fragment C. This is how am I going from fragment B to fragment C

HomeFragment nextFrag= new HomeFragment();
             .replace(R.id.frame, nextFrag,"findThisFragment")
Mr.AF Reply to 2018-01-13 01:43:50Z

If you mean Action bar title you should consider that the title is set on main activity only once and also if you need the title depend on your current fragment your should create a function in your main activity in order to set the title again otherwise the title won't be change .

Here is the complete answer of how to change the title

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.247059 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO