It should be simple enough, but it may not be.
When using the action bar in Android 3.0+, you can define your menu items in XML or in code. I prefer to encode them in xml, because action panels perceive more of the user interface than functional ones.
On an average day, you would use this to inflate xml in a menu
@Override public boolean onCreateOptionsMenu(Menu menu) {
And your XML file will look like this:
<menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/menu_settings" android:orderInCategory="100" android:showAsAction="never" android:title="@string/menu_settings"/> <item android:id="@+id/menu_item_menu" android:icon="@drawable/menu_off_128" android:showAsAction="ifRoom|withText" android:title="@string/inbox_string"/> <item android:id="@+id/menu_item_gallery" android:icon="@drawable/gallery_off_128" android:showAsAction="ifRoom|withText" android:title="@string/gallery_string"/> <item android:id="@+id/menu_item_inbox" android:icon="@drawable/inbox_off_128" android:showAsAction="ifRoom|withText" android:title="@string/inbox_string"/> <item android:id="@+id/menu_item_contact" android:icon="@drawable/phone_off_128" android:showAsAction="ifRoom|withText" android:title="@string/contact_string"/> </menu>
Right now, I am facing the problem of making the taskbar backward compatible, and actionbarsherlock seems most enjoyable to use and popular. So I tried this with actionbarsherlock and, unfortunately, there are problems with compilation.
Namely, the Menu class returned by the inflatable device is "Android.view.menu" and not "com.actionbarsherlock.menu". I went through the samples on github, but they all have a menu defined in the code.
So, did anyone manage to get an actionbarsherlock menu that works with an XML-based layout?
Overone
source share