0

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?

Please help!

grgvn
  • 1,309
  • 1
  • 12
  • 25

2 Answers2

2

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

Answered here

Community
  • 1
  • 1
iDroid
  • 10,403
  • 1
  • 19
  • 27
0

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

Egor
  • 39,695
  • 10
  • 113
  • 130
  • Well.. Maybe I didn't explain my problem very well. I have the name of the resource "R.raw.room" in a String, and I want to find the ID of this "R.raw.room" – grgvn Jun 10 '11 at 12:05
  • You didn't explain your problem at all. Since R.raw.room is a composite identifier, I doubt you can parse a string to get it. So, why do you need such an approach? – Egor Jun 10 '11 at 12:08