I'm trying to override the options menu in my android. The onCreateOptionsMenu method gets called when using an emulator with Android 4.
My main Activity extends ActionBarActivity, and I make the required setHasOptionsMenu true call in the onCreate of my Fragment. I've tried both ActionBarCompat and ActionBarSherlock, and I have the same exact issue with both libraries.
android - onCreateOptionsMenu() is not getting called on FragmentActivity - Stack Overflow
I'm not sure however I'll try to help you. With ABS, I answered on a "same" behaviour and it worked well. Then, with AppCompatyou have to call super method after all your stuff as follows:.
You have a great explaination and example on this answer. You should also check your imports. However it's maybe related to your device and not with the way you do it not sure, because on 4.
Tour Start here for a quick overview of the site Help Center Detailed answers to any questions oncreateoptionsmenu not called fragment might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us.
Log In Quick ways to make money in dallas tx Up. Join the Stack Overflow Community.
Stack Overflow is a community of 7. Join them; it only takes a minute: Works on emulator, not on device Ask Question. Sachin K 2 Then, with AppCompatyou have to call super method after all your stuff as follows: Fllo 9, 5 22 Your linked answer was very helpful.
android - onCreateOptionsMenu not called in Fragment. Works on emulator, not on device - Stack Overflow
In this particular case I was running into an Exception before onCreateOptionsMenu was hit. Once that code was removed, the method was being called just fine. Still not sure why it was an issue on the 4.
android - onCreateOptionsMenu is never called - Stack Overflow
Really glad to help. Rana Ranvijay Singh 2, 2 19 I used inside onCreate and works. Sign up or log in StackExchange.
Sign up using Facebook.