Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error:no resource identifier found for attribute"showAsAction" in package 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" 

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"/>

like image 211
Mayu11 Avatar asked Mar 29 '13 12:03

Mayu11


2 Answers

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

like image 89
Taras Avatar answered Oct 27 '22 00:10

Taras


"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>
like image 20
Dhanesh Avatar answered Oct 26 '22 23:10

Dhanesh