I implemented ActionBarCompat to have an ActionBar across different OS versions.
It is hidden on smartphones, and displayed only on tablets.
I see that in this screenshot: http://developer.android.com/resources/samples/ActionBarCompat/index.html, the Share option menu displays the Logout option in a submenu, but when I compiled and run the sample code on a tablet, the Logout option was completely hidden and there wasn’t any option to display it as a submenu
Then I tried to do something like this:
<item
android:icon="@android:drawable/ic_menu_delete"
android:orderInCategory="1"
android:showAsAction="always"
android:title="@string/menu_logout">
<menu>
<item
android:id="@+id/menu_logout"
android:title="@string/menu_logout"/>
</menu>
</item>
And it really looks how I want – on a tablet, on a smartphone however, it has an undesired effect – when clicking the Logout option menu, it displays another context menu, which is because of nested menus I believe.
Do you know guys, how can I display a submenu when using the Action Bar on a tablet, and display just a regular option menu on smartphone? Maybe ActionBarCompat requires some additional configuration?
I found a solution.
The solution consists of having 2 separate menu resources files, for tablets and for smartphones: menu_tablet.xml, menu_smartphone.
For tablets, I display a submenu:
For smartphones I display as a regular option menu:
And then in the code I inflate the appropriate menu resource like this: