error: Error retrieving parent for item: No resource found that matches the given name 'android:Wind
2012-04-28 01:03
701 查看
当你的androidAPI 由2.1版本更换成2.2版本时:
res/vavlues/styles.xml中使用的android:WindowTitle会报以下异常,
error: Error retrieving parent for item: No resource found that matches the given name 'android:WindowTitle'.
从而导致我们的程序无法编译通过。
原因:
android2.1中的某些API(包括类方法或者XML属性)更换成android2.2时,它们的路径已经发生了改变,从而导致编译器无法找到它们,所以编译无法通过。
解决方案:
1. 在Eclipse中打开任意一个.java文件,输入
android.R.style.
这时你会看到一个提示列表,仔细看看,里面确实没由WindowTitle, 但是我们发现了一个TextAppearance_WindowTitle. 没错, 在android2.2中,它已经被改成了TextAppearance_WindowTitle。
2. 回到报错的res/values/styles.xml, 将<style name="XWindowTitle" parent="">
相应地修改成
<style name="XWindowTitle" parent="android:TextAppearance.WindowTitle">
注意:这里你也许会注意到 .java文件中的XML属性,与 .xml文件中XML属性很是类似。
这不是巧合,android官方文档规定:
java文件中的android.R.style.TextAppearance_WindowTitle 对应
xml文件中的android:TextAppearance.WindowTitle。 “下划线”与“点”时对应关系。
关于Styles and Themes 之间的关系,请参考官方网站
http://developer.android.com/guide/topics/ui/themes.html
res/vavlues/styles.xml中使用的android:WindowTitle会报以下异常,
error: Error retrieving parent for item: No resource found that matches the given name 'android:WindowTitle'.
从而导致我们的程序无法编译通过。
原因:
android2.1中的某些API(包括类方法或者XML属性)更换成android2.2时,它们的路径已经发生了改变,从而导致编译器无法找到它们,所以编译无法通过。
解决方案:
1. 在Eclipse中打开任意一个.java文件,输入
android.R.style.
这时你会看到一个提示列表,仔细看看,里面确实没由WindowTitle, 但是我们发现了一个TextAppearance_WindowTitle. 没错, 在android2.2中,它已经被改成了TextAppearance_WindowTitle。
2. 回到报错的res/values/styles.xml, 将<style name="XWindowTitle" parent="">
相应地修改成
<style name="XWindowTitle" parent="android:TextAppearance.WindowTitle">
注意:这里你也许会注意到 .java文件中的XML属性,与 .xml文件中XML属性很是类似。
这不是巧合,android官方文档规定:
java文件中的android.R.style.TextAppearance_WindowTitle 对应
xml文件中的android:TextAppearance.WindowTitle。 “下划线”与“点”时对应关系。
关于Styles and Themes 之间的关系,请参考官方网站
http://developer.android.com/guide/topics/ui/themes.html
相关文章推荐
- error: Error retrieving parent for item: No resource found that matches the given name 'android:Wind
- Android错误之--Error retrieving parent for item: No resource found that matches the given name 'Theme.A
- Error retrieving parent for item: No resource found that matches the given name 'android:Theme....
- error: Error retrieving parent for item: No resource found that matches the given name 'android:Win
- error: Error retrieving parent for item: No resource found that matches the given name 'android:Them
- Error retrieving parent for item: No resource found that matches the given name 'android:TextAppeara
- android导入工程时style出错Error retrieving parent for item: No resource found that matches the given name '
- Android Error retrieving parent for item: No resource found that matches the given name '...'
- Error retrieving parent for item: No resource found that matches the given name 'android:TextAppeara
- error: Error retrieving parent for item: No resource found that matches the given name 'Theme.Ap
- error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCo
- error: Error retrieving parent for item: No resource found that matches the given name 'android:Wind
- error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCom
- 解决error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppC
- error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCom
- Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.A
- 解决error: Error retrieving parent for item: No resource found that matches the given name 'AppCompat'
- Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:T
- Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:T
- Android:Error retrieving parent for item: No resource found that matches the given name解决方法