【问题标题】:Error retrieving parent for item: No resource found that matches the given name '@android:style/TextAppearance.Holo.Widget.ActionBar.Title'检索项目的父项时出错:找不到与给定名称“@android:style/TextAppearance.Holo.Widget.ActionBar.Title”匹配的资源
【发布时间】:2012-01-25 07:21:05
【问题描述】:

我正在实现 ActionBar 以在 xml 中使用此样式脚本设置文本的颜色,但是当我运行我的应用程序时出现错误有人知道我缺少什么

这是我的 style.xml 文件

<!-- Start with the Holographic Light theme -->
<style name="Theme.IOSched" parent="android:style/Theme.Holo.Light">
    <item name="android:windowBackground">@drawable/window_background</item>
    <item name="android:actionBarStyle">@style/ActionBar</item>

    <!-- custom attributes 
    <item name="textHeaderMaxLines">@integer/text_header_max_lines</item>
    <item name="trackAbstractMaxLines">@integer/track_abstract_max_lines</item>-->
</style>

<style name="Theme.IOSched.Home" parent="style/Theme.IOSched">
    <item name="android:windowBackground">@drawable/window_background_home</item>
    <item name="android:actionBarStyle">@style/ActionBar</item>
</style>

<style name="ActionBar" parent="android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">@color/actionbar_background</item>
    <item name="android:textColor">@color/accent_1</item>
    <item name="android:titleTextStyle">@style/ActionBarText</item>
</style>

<style name="ActionBarText" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title"> <!-- getting here error-->
    <item name="android:textColor">@color/accent_1</item>
    <item name="android:textStyle">bold</item>
</style>

error: Error retrieving parent for item: No resource found that matches the given name '@android:style/TextAppearance.Holo.Widget.ActionBar.Title'.

【问题讨论】:

标签: android coding-style


【解决方案1】:

TextAppearance.Holo.Widget.ActionBar.Title 似乎已添加到 API 级别 13。确保您的构建目标设置为 13,而不仅仅是 11。

【讨论】:

  • 不得不提这一点很愚蠢,但我忘记了这一步,所以也许它也会对其他人有所帮助:不要忘记在更改项目的目标版本后“清理”项目!
【解决方案2】:

AndroidManifest.xml:

<uses-sdk
    android:minSdkVersion=...
    android:targetSdkVersion="11" />

项目属性 -> 项目构建目标 = 11 或以上

这两件事为我解决了问题!

【讨论】:

    【解决方案3】:

    我尝试将目标 sdk 更改为 13 但不起作用! 然后当我将compileSdkVersion 13 更改为compileSdkVersion 14 时编译成功:)

    注意:我使用的是 Android Studio 而不是 Eclipse

    【讨论】:

    • 谢谢你。像魅力一样工作。
    【解决方案4】:

    确保您已将项目属性(而非清单)中的目标 API(不同于目标 SDK)设置为至少 4.0/API 14。

    【讨论】:

    • 这个很完美。赞成。如果您再解释一些可以帮助我们更好地理解的内容,那就太好了。
    【解决方案5】:

    发生这种情况是因为在 r6 中,当您尝试扩展私有样式时会显示错误。

    参考这个link

    【讨论】:

      【解决方案6】:
      <style name="Theme.IOSched" parent="android:style/Theme.Holo.Light">
          <item name="android:windowBackground">@drawable/window_background</item>
          <item name="android:actionBarStyle">@style/ActionBar</item>
      </style>
      

      您不能在项目窗口背景中提供自己的颜色和背景。 在 /color.xml 文件中给出你的颜色。

      【讨论】:

        【解决方案7】:

        这是一个旧帖子,但如果有人提出这个问题,我发布解决了我的问题的方法:

        当我收到错误时,我正试图将 Action Bar Sherlock 添加到我的项目中:

        Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.ActionBar'.
        

        我发现action bar sherlock proyect 和我的proyect 有不同的minSdkVersiontargetSdkVersion。更改该参数以在两个项目中匹配解决了我的问题。

        <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="17"/>
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-10-27
          • 2014-06-04
          • 2017-02-10
          • 2017-06-27
          • 2017-09-25
          • 1970-01-01
          相关资源
          最近更新 更多