【问题标题】:Error retrieving parent for item: No resource found that matches the given name '@android:style/Theme.AppCompat.Light.DarkActionBar'检索项目的父项时出错:找不到与给定名称“@android:style/Theme.AppCompat.Light.DarkActionBar”匹配的资源
【发布时间】:2014-10-18 07:12:35
【问题描述】:

我正在关注 developer.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>

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

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

请帮忙。我从早上开始就一直在做,但我什么也没有。

【问题讨论】:

  • Theme.AppCompat 样式不在android sdk 下,所以你使用parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse"
  • 你在使用 Android Studio 吗??
  • @Lucksprog,非常感谢!那行得通! goonerdroid,我正在使用 eclipse。

标签: java android eclipse


【解决方案1】:

尝试删除android:,像这样:

<style name="CustomActionBarTheme"
       parent="@style/Theme.AppCompat.Light.DarkActionBar">

【讨论】:

  • 太棒了,这对我有用。我什至没有“@”,但它起作用了。
猜你喜欢
  • 2016-12-23
  • 2012-01-25
  • 2015-08-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-27
  • 2014-06-04
  • 2017-02-10
相关资源
最近更新 更多