onCreate Options menu is not showing in android 3.1

半世苍凉 提交于 2019-12-10 20:44:39

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!