I have a fragment that I'm replacing with another, while also adding the transaction to the back stack. Both of my fragments provide menu items to the action bar using ActionBarSherlock. However, I'm having a problem -- in my second fragment, the action bar shows both the first fragment's and the second fragment's items; I only want the second one's items. Is there any way to achieve this?
(I'm also using the support library.)
If you want to update the action bar icons, you can override onCreateOptionsMenu() in the activity to define which menu is used for the active fragment. Then call invalidateOptionsMenu() after replacing fragments to recreate the menu.
If you're only using the drop down menu, you can override onPrepareOptionsMenu() and add/remove items from the menu.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With