If you want to update the action bar icons, you can override onCreateOptionsMenu () in the action to determine which menu is used for the active fragment. Then call invalidateOptionsMenu () after replacing fragments to recreate the menu.
If you use only the drop-down menu, you can override onPrepareOptionsMenu () and add / remove items from the menu.
source share