检索项目的父项时出错:找不到与给定名称匹配的资源'@android:style / TextAppearance.Holo.Widget.ActionBar.Title'

时间:2011-12-21 13:24:48

标签: android coding-style

我正在实现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'.

7 个答案:

答案 0 :(得分:80)

似乎已在API级别13中添加了

TextAppearance.Holo.Widget.ActionBar.Title。确保您的构建目标设置为13,而不仅仅是11。

答案 1 :(得分:16)

的AndroidManifest.xml:

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

项目属性 - &gt; 项目构建目标 = 11或以上

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

答案 2 :(得分:8)

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

  

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

答案 3 :(得分:4)

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

答案 4 :(得分:1)

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

请参阅此link

答案 5 :(得分:0)

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

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

答案 6 :(得分:0)

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

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

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

我发现动作栏sherlock proyect和我的proyect有不同的 minSdkVersion targetSdkVersion 。改变这两个proyect中匹配的参数解决了我的问题。

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