tasgr86
tasgr86

Reputation: 309

navigationview with different toolbar for each fragment

I'm implementing a navigationview in an Activity.When a navigationview item gets clicked a new fragment starts.My toolbar is defined in Activity and the problem is that i want to use different toolbars for each fragment.For example in one fragment the toolbar will contain a spinner, on another a couple of textviews etc.

What are my options here?I've thought of keeping the toolbar on Activity and inflate afterwards the views i need from fragment, but maybe there is a better approach?

Upvotes: 4

Views: 3589

Answers (1)

herrmartell
herrmartell

Reputation: 3117

I answered a very similar question here:

How to use different Toolbars on each Fragment

It's basically all about:

1) Creating 1 XML for each different Toolbar

2) Including them on your main Activity XML

3) Showing and hiding the desired Toolbar on each Fragment

Hope that helps.

Upvotes: 3

Related Questions