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?
精彩评论