Modify topbar between fragments of same activity

Viewed 40

I have been trying with several ways of getting this and not truly achieving it. What i want is simple, different fragments show different Topbars(or appbars, or toolbars) with different titles and options. As shown here:

topbar1 topbar2

Which is the proper way to implement this?

2 Answers

Its Quite easy. Set your toolbar inside your fragment xml code and call every different fragment in our one fragment container.

thus you will be able to create different toolbar for different fragment.

SOLUTION

I wasnt navigating to the main fragment so it was never executing the onCreate method properly as the topbar wasnt created yet

Related