Note that there are some explanatory texts on larger screens.

plurals
  1. POSherlockListFragment 'onCreateOptionMenu' crashes on android 2.3.3
    text
    copied!<p>I have a generic <code>SherlockListFragment</code> that is used in my App in different cases. This fragment has a Option Menu Item ( a <code>SearchView</code>), here is the code of the <code>SearchView</code> creation:</p> <pre><code> @Override public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.all_places, menu); final MenuItem searchMenuItem = menu.findItem(R.id.action_search); searchMenuItem.setOnActionExpandListener(this); final SearchView searchView = (SearchView) searchMenuItem .getActionView(); searchView.requestFocusFromTouch(); searchView.setQueryHint(getString(R.string.search_query_hint)); searchView.setOnQueryTextListener(this); } </code></pre> <p>The problem is that one of this fragments instances is used in a ViewPager, and when swiping to it, the app crashes (only on HTC Desire with android 2.3.3), but works on ICS and JB devices. By the way, when attaching the fragment manually (with no <code>ViewPager</code>) no crash occurs.</p> <p>Here is the stack trace of the crash:</p> <pre><code>java.lang.NullPointerException at android.view.View.dispatchRestoreInstanceState(View.java:6132) at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1213) at android.view.View.restoreHierarchyState(View.java:6116) at com.actionbarsherlock.internal.view.menu.MenuBuilder.restoreActionViewStates(MenuBuilder.java:361) at com.actionbarsherlock.internal.ActionBarSherlockCompat.preparePanel(ActionBarSherlockCompat.java:503) at com.actionbarsherlock.internal.ActionBarSherlockCompat.dispatchInvalidateOptionsMenu(ActionBarSherlockCompat.java:272) at com.actionbarsherlock.app.SherlockFragmentActivity.invalidateOptionsMenu(SherlockFragmentActivity.java:150) at com.actionbarsherlock.app.SherlockFragmentActivity.supportInvalidateOptionsMenu(SherlockFragmentActivity.java:156) at android.support.v4.app.Fragment.setMenuVisibility(Fragment.java:781) at android.support.v4.app.FragmentStatePagerAdapter.setPrimaryItem(FragmentStatePagerAdapter.java:151) at android.support.v4.view.ViewPager.populate(ViewPager.java:1009) at android.support.v4.view.ViewPager.populate(ViewPager.java:880) at android.support.v4.view.ViewPager$3.run(ViewPager.java:238) at android.os.Handler.handleCallback(Handler.java:587) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:144) at android.app.ActivityThread.main(ActivityThread.java:4937) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>I'm really stuck with this issue... any help will be great.</p> <p><strong>Edit</strong></p> <p>Switched to ActionBarSherlock dev branch - no crash... thanks everybody.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload