onCreateOptionsMenu not getting called inside the Fragment
onCreateOptionsMenu method is never called even though I have done all the steps from other similar questions (like this one: Menu inside fragment not getting called; and this: onCreateOptionsMenu not being called on FragmentActivity when run on phone version)
1) I call setHasOptionsMenu(true) in onCreate method of the Fragment
2) I override onCreateOptionsMenu(Menu menu, MenuInflater inflater) methd like this
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.main, menu);
}
[ 3) And also I dp implement onOptionsItemSelected(MenuItem item) ]
WTH?
PS I am using android-support-v4.jar.
PPS @Philipp Jahoda, I do implement onCreateOptionsMenu(...) in a Fragment's hosting Activity.
The problem is solved.
I am using ActionBarSherlock, but my fragment class was extending "Fragment" class instead of "SherlockFragment". So onCreateOptionsMenu method was not getting called.
That simple..
链接地址: http://www.djcxy.com/p/63916.html