My app runs great on the ICS emu. However, using Gingerbread, it crashes whenever my onCreateOptionsMenu is in use. It also throws another, similar but different set of errors if I use showPopup instead. Does anyone know what exactly is going on here? Ideally, I would like to have one bit of menu code (excluding the listener, of course) that will lay out a menu for all versions of android running the app. I should mention, though, that I have a GUI menu button (sitting in my XML file as an ImageView), rather than one in the ActionBar. So, here's the code:
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
return true;
}
Here's the menu XML:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/demographics"
android:title="@string/demographics" />
<item android:id="@+id/tabSelection"
android:title="@string/tabs" />
<item android:id="@+id/settings"
android:title="@string/settings" />
</menu>
And here's the LogCat:
threadid=1: thread exiting with uncaught exception (group=0x40015560)
FATAL EXCEPTION: main
java.lang.IllegalStateException: Cannot interact with object designed for temporary instance passing. Make sure you using both SherlockFragmentActivity and SherlockFragment.
at com.actionbarsherlock.internal.view.menu.MenuMule.add(MenuMule.java:40)
at android.view.MenuInflater$MenuState.addItem(MenuInflater.java:310)
at android.view.MenuInflater.parseMenu(MenuInflater.java:154)
at android.view.MenuInflater.inflate(MenuInflater.java:80)
at com.davekelley.polling.Polling.onCreateOptionsMenu(Polling.java:203)
at android.app.Activity.onCreatePanelMenu(Activity.java:2158)
at android.support.v4.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:209)
at com.actionbarsherlock.app.SherlockFragmentActivity.onCreatePanelMenu(SherlockFragmentActivity.java:236)
at com.actionbarsherlock.ActionBarSherlock.callbackCreateOptionsMenu(ActionBarSherlock.java:543)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.preparePanel(ActionBarSherlockCompat.java:467)
at com.actionbarsherlock.internal.ActionBarSherlockCompat.dispatchInvalidateOptionsMenu(ActionBarSherlockCompat.java:269)
at com.actionbarsherlock.internal.ActionBarSherlockCompat$1.run(ActionBarSherlockCompat.java:972)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)