我的Android应用程序将最小sdk和目标sdk设置为10,当我在Nexus 4 -Android版本4.2.2上运行我的应用程序时,它会在系统导航旁边显示一个菜单选项按钮。
我没有在我的应用程序中使用菜单选项,我不想向用户显示这个无用的菜单选项。我该如何删除它?
我在http://android-developers.blogspot.com.au/2012/01/say-goodbye-to-menu-button.html上已经读过这个,但我没有得到具体的解决方案。
附件是图片:
我不想更改我的应用程序的sdk版本。是否可以在不更改sdk版本的情况下删除菜单选项?
答案 0 :(得分:2)
您只需将targetSdk
修改为10以上的内容。例如,如果您使用上一个SDK,则应使用targetSdk=16
答案 1 :(得分:0)
具体解决方案在文章中:
为您的应用添加主题:
<application android:theme="@style/NoActionBar">
然后在res / values / themes.xml中为pre-Honeycomb定义此主题:
<resources>
<style name="NoActionBar" parent="@android:style/Theme">
<!-- Inherits the default theme for pre-HC (no action bar) -->
</style>
</resources>
以及Honeycomb及其后期:
<resources>
<style name="NoActionBar" parent="@android:style/Theme.Holo.NoActionBar">
<!-- Inherits the Holo theme with no action bar; no other styles needed. -->
</style>
</resources>
答案 2 :(得分:-1)
如果您将目标SDK版本设置为11及更低版本,则会显示android旧版菜单按钮。但是,如果您想要保留目标SDK版本,则可以删除方法onCreateOptionsMenu
,这样您就不会对任何选项进行充气。