Referencing Options Menu Item As View Throws Nullpointerexception
I'm building user guide with MaterialShowcaseView library. I plan to guide user through all toolbar options menu items in fragment (Theme.AppCompat with no action bar is used). Thu
Solution 1:
Since the fragment equivalent is already giving you a MenuInflater, probably try doing this..
@OverridepublicvoidonCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_sample, menu);
super.onCreateOptionsMenu(menu,inflater);
}
May be in your case, getActivity()
may be throwing a null pointer because the onCreate
method of Activity is called first, and before it finishes onCreateOptionsMenu
is called.
Post a Comment for "Referencing Options Menu Item As View Throws Nullpointerexception"