本文介绍了当 API 级别高于 10 时,Android 菜单图标不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Android 中的菜单选项测试某些内容.我注意到如果 targetSdkVersion 大于 10,则菜单图标不会显示...

I am trying to test something with menu options in Android.. And I noticed that menu icons are not displaying if the targetSdkVersion is greater than 10...

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
   <item android:id="@+id/about" android:title="@string/about_label"
   android:icon="@android:drawable/ic_menu_info_details" android:alphabeticShortcut="a" />
   <item android:id="@+id/help" android:title="@string/help_label"
   android:icon="@android:drawable/ic_menu_help" android:alphabeticShortcut="h" />
</menu>

我正在尝试调试,但不知道从哪里开始.

I am trying to debug, and I am not sure where to start.

推荐答案

从 API 级别 11 (Android Honeycomb) 开始,Android 引入了菜单的新概念.为该 API 级别构建的设备不再有菜单键.一个新的 UI 组件不是在按下键后显示菜单:Actionbar.操作栏现在显示空间允许的尽可能多的菜单项,然后创建一个按钮,将在叠加层中显示其余菜单项.

Starting with API Level 11 (Android Honeycomb) Android introduced a new concept for menus. Devices build for that API Level do not have a menu key anymore. Instead of showing a menu after a key is pressed there is a new UI Component: the Actionbar. The Actionbar now shows as much menu items as the space allows and after that creates a button that will show the rest of the menu items in an overlay.

我假设您正在为您的活动使用某种主题,以防止出现操作栏,因此没有菜单项可见.另请阅读有关如何支持平板电脑和手机的指南,以开始了解新的操作栏有效.

I would assume that you are using some kind of theme for your activity that prevents the Actionbar from appearing and therefore no menu items are visible. Also read the guide on how to support Tablets and Handsets to begin to understand how the new actionbar works.

这篇关于当 API 级别高于 10 时,Android 菜单图标不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 11:10