I would like to be able to append action bar items from my fragments.
For example in Landscape mode I have a list of items, and if clicked a page of information about that item appears.
The list can be changed by clicking the dropdown in the action bar to select a category of list.
Once a list item is clicked the details fragment is populated. I then want 3 tabs to be appended into the action bar so that the user can select which page of details is shown for that item, namely: “Details (default)”;”Map”; and “Features”.
In my fragment I can set setHasOptionsMenu(true) and then add the new tabs using the onCreateOptionsMenu call. This however deletes my dropdown which i still want displayed.
How does one simply append ActionBar Items..?
Thanks
I just call the fragment’s
onCreateOptionsMenufrom my activity’sonCreateOptionsMenu. You can add an if statement to decide to call the fragment’s version or default call the fragment’sonCreateOptionsMenuand put the if statement there to decide what to add. then, whenever it needs to change, just callinvalidateOptionsMenu.You will probably have to remove the
setHasOptionsMenucall.Activity:
Fragment: