问题
i am creating an app only for tablets. I have a preference activity page which i am calling through the OnCreateOptions Menu. The oncreateoptins menu is not working in tablets of android 3 version. Why it is so, i used a Samsung galaxy tab for my testing. When i run the same app in one of my emulator of Samsung galaxy tablet of android 2.2 i am getting the oncreate options menu, can anyone help me in this
回答1:
I think problem is in different handling of options menu. According to dev guide, on Android 3.x onCreateOptionsMenu()
is called when the activity starts to populate ActionBar, not when user touches the Menu button for the first time
回答2:
Yes this problem is common , Do one thing give a number less than 11 in the targetSdkVersion in Manifest file or simply remove the tarketSdkVersion. Your problem will be get resolved.
回答3:
I had the same problem on tablets and I did like raman suggested. Changed the project's build target and the targetSdkVersion (from manifest) to 10.
来源:https://stackoverflow.com/questions/8061409/oncreate-options-menu-is-not-showing-in-android-3-1