1

我有一个包含菜单选项的应用程序,但在某些 Jelly Bean 设备中,我们没有菜单软键按钮,所以在这种情况下如何显示这些菜单选项?我是否需要检查 sdk 版本,基于它我必须实现功能?而且我无法在我的应用程序中使用 hasPermanentMenuKey() 函数。
我的应用目标

android:minSdkVersion="9"
android:targetSdkVersion="17"

谁能给我任何建议?

4

3 回答 3

1

我想,你一定在 Android Manifest 中给出了 android-9 特定的主题。示例 android:theme="@android:style/Theme.Light"

1) Since Android 4.0 we have Action Bar, so many of the device running Android 4.0 and above will not have Hardware Menu.
2) All your Menu will be in action bar.
3) So, you need to specify different theme to Android v-14 and above, for you app to display Action bar with your menu.otherwise you will not get Action bar so as you Menu.

How To Do It
1) In values/styles.xml 
    <resources>
        <style name="AppBaseTheme" parent="android:Theme.Light"></style>
            <style name="AppTheme" parent="AppBaseTheme"> </style>
    </resources>

2) In values-v14/styles.xml
    <resources>
         <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar"></style>
    </resources>

3) In AndroidManifest.xml
      android:theme="@style/AppTheme" 
于 2013-10-26T11:17:08.573 回答
0

使用较低的 minSDKVersion。然后在这些设置中也将有一个用于选项菜单的软键。例如

android:minSdkVersion="5"
于 2013-10-26T10:22:41.667 回答
0

由于 ActionBar 是在 HoneyComb 中引入的,因此您使用 onCreateOptionsMenu 设置的菜单会显示在活动的 ActionBar 上。如果您指定该android:showAsAction="never|withText"项目进入溢出菜单...看起来像三个点的东西并显示为全文.

您可以使用与 pre HoneyComb 相同的 API:

    boolean onCreateOptionsMenu(Menu menu)
    boolean onOptionsItemSelected(MenuItem item)
于 2013-10-26T11:00:27.887 回答