开发者

Link XML to Resources

开发者 https://www.devze.com 2023-03-12 04:27 出处:网络
I have an XML file: <building> <room IMAGE=\"R.raw.room\" /> </building> but I don\'t know how to link the value of IMAGE to my main program... When I do this:

I have an XML file:

<building>
    <room IMAGE="R.raw.room" />
</building>

but I don't know how to link the value of IMAGE to my main program... When I do this:

[... parsing xml file and detect room ...]
ImageView image = findViewByID(xml.getAttributeValue(0));

it don't works.. Cause it returns me a String and not a int. How can I link this XML file to my resources?

开发者_Python百科

Please help!


Have you tried using getResources().getIdentifier()?

Answered here


R.raw.room is an identifier generated by compiler for a file. You cannot load from XML. What do you want to achieve?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号