“找不到属性“showAsAction”的资源标识符;在包“android”中
我正在尝试更新我的 Android 应用程序,以便在运行 Honeycomb 的平板电脑上看起来更好。因此,我的目标是 SDK 版本 11(我的 minSdkVersion = 4)。这会将 Honeycomb 主题添加到我的应用程序中,使其看起来更好。但是,我无法访问我的菜单选项。因此,我尝试将菜单项添加为操作栏项,并在 /res/menu/ 文件夹中的文件中添加以下内容:
android:showAsAction="ifRoom|withText"
但是,我收到以下错误:
在包“android”中找不到属性“showAsAction”的资源标识符
我尝试将 minSdkVersion 号更改为 11 以查看它是否有效,但没有运气。有什么想法吗?谢谢!
I am attempting to update my android application to look better for tablets running Honeycomb. As such, I am targeting version 11 of the SDK (my minSdkVersion = 4). This adds the Honeycomb theme to my app, making it look better. However, I have no way to access my menu options. So, I am attempting to add my menu items as an action bar item with the following in the file in my /res/menu/ folder:
android:showAsAction="ifRoom|withText"
However, I get the following error:
No resource identifier found for attribute 'showAsAction' in package 'android'
I tried altering my minSdkVersion number to 11 to see if it would work, but no luck. Any ideas? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
如果您使用 Eclipse 进行构建,请确保项目的构建目标也设置为 Honeycomb。
If you are building with Eclipse, make sure your project's build target is set to Honeycomb too.
从每个 xml 文件的
res/menu
文件夹中删除android:showAsAction="never"
。remove
android:showAsAction="never"
fromres/menu
folder from every xml file.以上所有修复可能无法在 android studio 中工作。如果您使用的是 ANDROID STUDIO......请使用此修复
添加
xmlns:compat="http: 菜单标记中的//schemas.android.com/tools"
而不是
xmlns:compat="http://schemas.android.com/apk/res-auto"
中的 >菜单标签。
all above fix may not work in android studio .if you are using ANDROID STUDIO...... use this fix
add
xmlns:compat="http://schemas.android.com/tools"
in menu tag instead of
xmlns:compat="http://schemas.android.com/apk/res-auto"
in menu tag.
将“android-support-v7-appcompat.jar”添加到 Android 私有库
Add "android-support-v7-appcompat.jar" to Android Private Libraries
将
compat
库编译添加到 build.gradle 文件中:Add
compat
library compilation to the build.gradle file:该问题与 AppCompat 库有关。有了它,您就可以
获得并可能:
在 menu.xml 文件中
如果没有该库,您只能拥有:
并且我的应用程序可以在 Android 4.3 和 2.3.3 上使用菜单。
The problem is related to AppCompat library. With it, you have
and possibly:
in menu.xml file.
Without the lib, you can only have:
and my app works with menu both on Android 4.3 and 2.3.3.
检查应用程序 build.gradle 上的compileSdkVersion。将其设置为 21:
Check your compileSdkVersion on app build.gradle. Set it to 21:
转到 gradle,然后转到 app.buildgradle,然后将compileSDKVersion 设置为 21,然后如果需要,android studio 将下载一些文件
go to gradle and then to app.buildgradle then set compileSDKVersion to 21 and then if necessary the android studio will download some files
来自因用西班牙语编写而被删除的答案:
上述所有修复可能无法在 android studio 中工作。如果您使用 ANDROID STUDIO,请使用以下修复程序。
使用而不是
在菜单标签上
From answer that was removed due to being written in Spanish:
All of the above fixes may not work in android studio. If you are using ANDROID STUDIO please use the following fix.
Use
on the menu label instead of