dbDev
dbDev

Reputation: 1549

How do I make a Fragment display only select menu items when viewed with other fragments?

I have two framents, when viewed on a phone, one at a time, they each have their own menus. Some of the menu items are the same, between the two fragments.

When viewed on a tablet, side by side, they each bring in their own menu items and display them in the action bar. Unfortunately, since both fragments have some of the same menu items, like "Logout", some of the items are extra and not needed.

How can I let one fragment bring in all it's menu items and tell the other fragment to only bring in a few of it's menu items?

NOTE: This is not the duplicate menu item problem that occurs sometimes when the device is rotated. I had that problem too, but resolved it. ;)

Thanks!

Upvotes: 0

Views: 219

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006724

Some of the menu items are the same, between the two fragments.

Why?

Unfortunately, since both fragments have some of the same menu items, like "Logout", some of the items are extra and not needed.

Logout then is not the responsibility of either fragment, but of the activity that is hosting the fragments. Have the activity be the one to add that action bar item, rather than either fragment.

Upvotes: 3

Related Questions