“No resource identifier found for attribute 's

2020-01-26 06:55发布

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!

8条回答
ら.Afraid
2楼-- · 2020-01-26 07:17

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.

查看更多
We Are One
3楼-- · 2020-01-26 07:18

If you are building with Eclipse, make sure your project's build target is set to Honeycomb too.

查看更多
【Aperson】
4楼-- · 2020-01-26 07:23

Add "android-support-v7-appcompat.jar" to Android Private Libraries

查看更多
再贱就再见
5楼-- · 2020-01-26 07:28

go to gradle and then to app.buildgradle then set compileSDKVersion to 21 and then if necessary the android studio will download some files

查看更多
混吃等死
6楼-- · 2020-01-26 07:36

The problem is related to AppCompat library. With it, you have

xmlns:appname="http://schemas.android.com/apk/res-auto"

and possibly:

appname:showAsAction="never"

in menu.xml file.

Without the lib, you can only have:

android:showAsAction="never"

and my app works with menu both on Android 4.3 and 2.3.3.

查看更多
smile是对你的礼貌
7楼-- · 2020-01-26 07:37

Add compat library compilation to the build.gradle file:

compile 'com.android.support:appcompat-v7:19.+'
查看更多
登录 后发表回答