No resource identifier found for attribute 'showAsAction' in package 'android'

前端 未结 7 1889
花落未央
花落未央 2021-02-13 19:30

as the title suggest, I\'m getting that error in at least 3 of the XML layout files, however, I dont see the attritube \"showsAsAction\" in any of those XML files, did I miss so

相关标签:
7条回答
  • 2021-02-13 19:44

    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.

    0 讨论(0)
  • 2021-02-13 19:47

    you must choose an API 14 with version of 4.0 or grater because any version below 4.0 does not contain in its package the showAsAction attribute

    0 讨论(0)
  • 2021-02-13 19:53

    I had this problem when I forgot to add appcompat-v7:+ to my project dependencies. You can do it like this in build.gradle:

    dependencies {
      compile 'com.android.support:appcompat-v7:+'
    }
    

    And this is because I had the following in my menu.xml:

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

    and

    app:showAsAction="never"
    

    When I removed the xmlns:app namespace and just used android:showAsAction="never", I didn't need the appcompat-v7 library anymore.

    0 讨论(0)
  • 2021-02-13 19:56

    Are you sure you are looking in the right *.xml file? You seem to look for "showAsAction" in layout xmls, but it's parameter for the menu. Look rather into .../menu/your_activity.xml

    The problem you are dealing with is connected with using target less than 4.0 and/or API less than 14.

    So,

    a) change those parameters,

    b) change the value of showAsAction from "never" to "ifRoom".

    0 讨论(0)
  • 2021-02-13 19:57

    This happens if you have used the resourceidentifier "ShowAsAction" in your XML. This feature is available only from ver11 i guess. If you are trying to run the same on a lower API version this errror is produced. SOLUTION ->> Right click the project > Properties > Android> Build Target > Choose something greater than API 11

    0 讨论(0)
  • 2021-02-13 20:01

    The right answer is to use

    android:showAsAction="ifRoom"
    

    instead where android is

    xmlns:android="http://schemas.android.com/apk/res/android"
    
    0 讨论(0)
提交回复
热议问题