error:no resource identifier found for attribute“showAsAction” in package android

核能气质少年 提交于 2019-12-07 05:53:46

问题


I've been working on an Android project and encountered an error which I'm unable to solve for quite a while. Here is the error which says

error:no resource identifier found for attribute"showAsAction" 

in package android

and the error is in following file login_.xml

<item
    android:id="@+id/action_settings"
    android:orderInCategory="100"
    android:showAsAction="never"
    android:title="@string/action_settings"/>


回答1:


This attribute is introduced in API level 11. Check the min and target version of your app in Manifest file.




回答2:


"ShowAsAction" attribute is introduced in api 11. Change the minSdkVersion of your app in Manifest file.

If you want to use it for api lower than 11, then you have to use android support library "android.support.v4.app".

After importing support library, you have to make some changes in your login.xml file. for e.g replace "android:showAsAtion attribute" by "yourapp:showAsAction" and define "yourapp" in header in this way.

<menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:yourapp="http://schemas.android.com/apk/res-auto" >
<item
    android:id="@+id/action_settings"
    android:orderInCategory="100"
    yourapp:showAsAction="never"
    android:title="@string/action_settings"/>
</menu>



回答3:


Just remove android:showAsAction from xml file



来源:https://stackoverflow.com/questions/15703570/errorno-resource-identifier-found-for-attributeshowasaction-in-package-androi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!