您的位置:首页 > 其它

20151227-01 [工程配置] error: Error retrieving parent for item: No resource found that matches the give

2015-12-27 22:22 295 查看
1、直接删除parent=。。。

2、

转:http://www.devdiv.com/forum.php?mod=viewthread&tid=89826&page=1#pid557155

有时候在定义自己的style文件时会报:
error: Error retrieving parent for item: No resource found that matches the given name '@android:style/Widget.TextView.ListSeparator.White'.

我的style定义如下:
<style name="ListSeparator" parent="@android:style/Widget.TextView.ListSeparator.White">
        <item
name="android:background">@drawable/light_header_dither</item>
        <item
name="android:textColor">#ffEE2C2C</item>
</style>

提示错误大体是说,找不到我继承的style。
parent="@android:style/Widget.TextView.ListSeparator.White"表示继承系统的style。
查看源码可以看到系统定义如下:
    <style
name="Widget.TextView">
        <item
name="android:textAppearance">?android:attr/textAppearanceSmall</item>
        <item
name="android:textSelectHandleLeft">?android:attr/textSelectHandleLeft</item>
        <item
name="android:textSelectHandleRight">?android:attr/textSelectHandleRight</item>
        <item
name="android:textSelectHandle">?android:attr/textSelectHandle</item>
    </style>

    <style
name="Widget.TextView.ListSeparator.White">
        <item
name="android:textColor">?textColorPrimaryInverse</item>
        <item
name="android:background">@android:drawable/light_header_dither</item>
    </style>
但Eclipse只能链接到Widget.TextView这一层。
可能的原因是要不sdk没有这个style或者是这个style被设置为不公开的了。

对于非public的xml属性,可以在“@”后加个"*"解决,如下:

<item name="android:windowTitleStyle">@*android:style/Widget.TextView.ListSeparator.White</item>

或者有一个比较笨的方法,就是把源码里的那个style复制过来放到自己的xml里然后引用。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: