错误:找不到属性"showAsAction"的资源标识符.在android包中 [英] error:no resource identifier found for attribute"showAsAction" in package android

查看:147
本文介绍了错误:找不到属性"showAsAction"的资源标识符.在android包中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在从事Android项目,遇到一个错误,很长一段时间都无法解决.这是错误提示

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" 

android

并且错误在以下文件login_.xml

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

推荐答案

api 11中引入了"ShowAsAction"属性.在清单文件中更改应用程序的minSdkVersion.

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

如果要将它用于低于11的api,则必须使用android支持库"android.support.v4.app".

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

导入支持库后,您必须在login.xml文件中进行一些更改.例如,将" android:showAsAtion属性"替换为" yourapp:showAsAction "并以此方式在标头中定义"yourapp".

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>

这篇关于错误:找不到属性"showAsAction"的资源标识符.在android包中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆