My target is to apply style on individual Views. I've created a style in styles.xml like this:
<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>
the corresponding ID is generated in R.java and the following code is using the above style:
XmlResourceParser parser = context.getResources().getXml(R.style.apptheme_black);
AttributeSet attribs = Xml.asAttributeSet(parser);
LinearLayout tr = new LinearLayout(context, attribs);
I get following exception while running:
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)
What am I doing wrong?
getXml method is used for fetching xml resources out from res/xml folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With