I am new to fragments and Ive been wondering whats the correct answer to this. I am having simple List > Detail type of application, where this was originally 2 activities, no fragments, each had their own actionbar (menu).
Now I want to migrate it to fragments.
Using fragments I created a classic tablet split view with list on the left, detail on the right. Obviously that being only one activity, only the list's actionbar (action items) is being displayed.
Where should I put the action items from the detail? What the correct pattern? Should I create an alternative resource folder with custom menu file for tablets which would consist of both list's and detail's menu items?
Thanks !
Just create a new fragment_details.xml for the details fragment's menu entries. Inflate the menu directly from the fragment. Inflate the base menu from the list fragment. The activity should have no menu attached at all as all menu entries are attached to the one or the other fragment.
In the tablet case, android will merge the fragment's menu with the one from the list fragment. On smaller screens, when only the details are shown, the fragment's menu is shown.