简体   繁体   中英

Android: Toolbar layout denpend on current fragment

First at all, i have a main activity with a toolbar. This toolbar is used for all my fragments.

For each fragment i have some difference menu items. And the GUI for it quite complex.

I know there is the way that create menu for each fragment then use setHasOptionsMenu(true). But, when use the menu like that, it too hard to custom all the menu item as i want.

So, i created a toolbar with many layouts. Set it "gone" by default. When adding a fragment i going to set the corresponding layout visible and hide all other.

It solved my problem but i'm not satisfied with this solution. And i wonder if you have any better solution for it. Please share!

我已经回答了与您需要的类似的东西...在这里看一下使用工具栏下的不同布局

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM