JakeWharton/ActionBarSherlock — Issue #234: NPE in onCreateOptionsMenu
Author: mykolka
Created: 2012-02-09 12:05:33+00:00
State: open

Hi, Jake!
I have a problem with new beta6.
When I try to get submenu item like this
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.categories_menu, menu);
MenuItem item = menu.findItem(R.id.im_sort);
MenuItem subItem = item.getSubMenu().getItem(app.currentSort);
subItem.setChecked(true); //Here is NPE, because subItem==null;
super.onCreateOptionsMenu(menu, inflater);

}

I have exception with NPE ONLY on ICS (Emulator with 4.0.3). But on my device with 2.3.3 all just fine. And i didnt have any problems with this code on previous beta (and I think on 3.5). Is it a bug or we have some trick here?