GetXml (id) - Resource exception not found

My goal is to apply style to individual View

s. I created the style styles.xml

as follows:

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

generated in R.java

, and the following code uses the specified style:

    XmlResourceParser parser =    context.getResources().getXml(R.style.apptheme_black);
    AttributeSet attribs = Xml.asAttributeSet(parser);

    LinearLayout tr = new LinearLayout(context, attribs); 

      

I am getting the 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?

+3


source to share


1 answer


getXml is used to fetch xml resources from res / xml folder .



+1


source







All Articles