In one class I inflate the action bar to find an item and then I return super.oncreatemenuoptions(menu) then in the other class I just use menu.finditem... In the onCreateMenuOptions method without inflating because when I inflated it again two of the items were created. It works fine on Api 15 and 16 but android 4.2.2 throws a null pointer exception whenever I try to use the item in the second class. The phone it crashes on is a Samsung Galaxy s4. Is there any firmware issues with Samsung? Is there anyway around this by checking api in my code? Class 1:
@Override
public boolean onCreateOptionsMenu(Menu menu)
Menuinflater inflater= getMenuInflater();
inflated.inflate (R.menu.actionbar, menu);
MenuItem item= menu.findItem(R.id.search);
return super.onCreateOptionsMenu(menu);
Class 2:
@Override
public void onCreateOptionsMenu (Menu menu,MenuInflater inflater) {
SearchView SearchView = (SearchView) menu.findItem (R.id.search).getActionView();
}
I fixed it by changing the search view android:showAsAction in the menu folder xml from "ifroom" to "always." Also moving the searchView.setOnQueryTextListener(this) from onCreateView to onCreateOptionsMenu but now when I do that it wont work on the older device and vice-versa when I move it back... I think this is a bug with api 19 or newer apis or something.