开发者

Link XML to Resources

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜