Wierd bug


#1

in the book, the code to create the options menu looks like this:

Listing 28.15 Configure SearchView (PhotoGalleryFragment.java)
@Override
@TargetApi( 11)
public void onCreateOptionsMenu( Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu( menu, inflater);
inflater.inflate( R.menu.fragment_photo_gallery, menu);
if (Build.VERSION.SDK_INT > = Build.VERSION_CODES.HONEYCOMB) {
// Pull out the SearchView MenuItem
searchItem = menu.findItem( R.id.menu_item_search);

SearchView searchView = (SearchView) searchItem.getActionView();
// Get the data from our searchable.xml as a SearchableInfo SearchManager searchManager = (SearchManager) getActivity() .getSystemService(
Context.SEARCH_SERVICE); ComponentName name = getActivity(). getComponentName(); SearchableInfo searchInfo = searchManager.getSearchableInfo( name);
searchView.setSearchableInfo( searchInfo); } }

Hardy, Brian; Phillips, Bill (2013-03-29). Android Programming: The Big Nerd Ranch Guide (Big Nerd Ranch Guides) (Kindle Locations 10973-10983). Pearson Education. Kindle Edition.

on my note2 the last item does not show until l flip the device to horizontal.

if I change the code by putting this line at the end:

super.onCreateOptionsMenu( menu, inflater);

then all is well. several of the menus in the book do this to me.
not sure why. it was driving me nuts, took a long time to find.
can anyone explain?


#2

um, i was wrrrrrong

the problem is its in the overflow menu which is a softkey on the note2 device. there is no visible indicator that there is anything in the overflow…it sucks. so remember to hit the menu. If i remember right on some devices there is an indication that an item is in the overflow

[the reason it thought it was fixed is because i set it to always show, ran it, changed the xml to ifroom and id not save rebuild and run… i think ] :blush:


#3

Yeah, that’s a classic action bar/options menu issue that we unfortunately do not explain completely. Glad you got it figured out!