检索项目的父项时出错:找不到与给定名称匹配的资源'@android:style/Theme.AppCompat.Light.DarkActionBar'

the*_*oon 6 java eclipse android

我正在关注来自developers.android.com的android开发教程,目前我正在尝试使用此处给出的信息设置我的操作栏:https://developer.android.com/training/basics/actionbar/styling. HTML#CustomBackground7

这是res/values/themes.xml的代码:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- the theme applied to the application or activity -->
    <style name="CustomActionBarTheme"
           parent="@android:style/Theme.AppCompat.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
        <!-- Support library compatibility -->
        <item name="actionBarStyle">@style/MyActionBar</item>

    </style>

    <!-- ActionBar styles -->
    <style name="MyActionBar"
           parent="@android:style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
        <item name="android:background">@drawable/actionbar_background</item>
        <!-- Support library compatibility -->
        <item name="background">@drawable/actionbar_background</item>

    </style>
</resources>
Run Code Online (Sandbox Code Playgroud)

我在"样式"开始标记旁边看到红色十字图标,悬停在错误消息上:错误:检索项目的父项时出错:找不到与给定名称匹配的资源'@android:style/Theme.AppCompat.Light.DarkActionBar ".

  • 我的应用程序有minSdkVersion ="11"和targetSdkVersion ="21",我尝试将minSdkVersion更改为13,14,但它没有区别
  • 有人建议检查appcompat是否已被标记为库项目,我检查了它,并在appcompat属性窗口中选中了"isLibrary"选项.
  • 我还确保appcompat作为库项目添加到我的项目中.
  • 从"@android:style"中删除"@android"或删除"@"不起作用.但是在第一个样式标记中,当我删除"@android"时,红色十字标记会消失,但第二个样式标记不会发生这种情况.

请帮忙.我从早上起就一直在这里,而且我没有到达任何地方.

小智 10

尝试删除android:,像这样:

<style name="CustomActionBarTheme"
       parent="@style/Theme.AppCompat.Light.DarkActionBar">
Run Code Online (Sandbox Code Playgroud)