View
我的目标是在个人s上应用样式。我创建了styles.xml
这样的样式:
<style name="trLinearLayout">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:orientation">vertical</item>
<item name="android:background">@android:color/white</item>
</style>
对应ID
的生成在R.java
,下面的代码使用了上面的样式:
XmlResourceParser parser = context.getResources().getXml(R.style.apptheme_black);
AttributeSet attribs = Xml.asAttributeSet(parser);
LinearLayout tr = new LinearLayout(context, attribs);
运行时出现以下异常:
04-10 16:41:52.053: W/ResourceType(283): Requesting resource 0x7f050005 failed because it is complex
04-10 16:41:52.065: W/System.err(283): android.content.res.Resources$NotFoundException: Resource ID #0x7f050005
04-10 16:41:52.065: W/System.err(283): at android.content.res.Resources.getValue(Resources.java:891)
04-10 16:41:52.065: W/System.err(283): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1865)
04-10 16:41:52.065: W/System.err(283): at android.content.res.Resources.getXml(Resources.java:779)
我究竟做错了什么?