I have an action that extends the ActionBarActivity included in the revision of support package 18. I have a menu item that contains a submenu, and it works great when loading the application. However, if I call supportInvalidateOptionsMenu (), for some reason the submenu no longer appears. The linked code will be the xml for the menu
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:myapp="http://schemas.android.com/apk/res-auto" > <item android:id="@+id/menu_search" android:icon="@drawable/ic_search" android:title="@string/menu_search" myapp:actionViewClass="android.support.v7.widget.SearchView" myapp:showAsAction="always|collapseActionView"/> <item android:id="@+id/menu_now_playing" android:icon="@drawable/ic_nowplaying" android:title="@string/menu_nowplaying" myapp:showAsAction="always"/> <item android:id="@+id/menu_station_overflow" android:icon="@drawable/ic_overflow" android:title="@string/more" myapp:showAsAction="always"> <menu> <item android:id="@+id/menu_favorite" android:icon="@drawable/ic_favorite" android:title="@string/favorite"/> </menu> </item> </menu>
And then the code to create the menu
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main_activity, menu); return super.onCreateOptionsMenu(menu); }
I should note that this problem occurs on Gingerbread devices, but there is no problem with android 4.x. Does anyone know what could be happening here?
source share