purbeast0
No Lifer
Well I'm having an issue here with my Android app and I am not sure how to do this or if it is even possible, and if it isn't, I have to figure something else out.
Now in my /res/drawable folder I have a bunch of .gif files, about 150, which represent icons that are used in my app. Some example files are d.gif, b.gif, db.gif, and dp-p.gif
I also have XML files that store the name of the image that I want to display. It doesn't return the .gif, it will simply return db and dp-p when I parse the XML file.
So for example, I parse an XML file, get a string of dp-p, and I know that is the image that I want to display.
So the way in general I've been calling images to draw is I will have an ImageView and set the icon based on the resource named R.id.<resource name>, and that variable will return an integer ID to the icon, and the draw function knows what to draw based on my ID.
So for instance, to draw the dp-p.gif I would call the image draw function and pass it R.id.dp-p and it would know which image to draw.
The problem I'm having is that since this is dynamically loaded from the value in the XML file, I am not sure how I can just kind of append the R.id. and the value in my XML string in order to pass it into the drawing function, since I'm trying to append an actual string to a variable name.
This is kind of hard for me to explain and I am not sure what to even google search for, but if anyone has any suggestions that would be great, thanks. If you have more questions about my explanation just ask and I will try to explain it better.
Now in my /res/drawable folder I have a bunch of .gif files, about 150, which represent icons that are used in my app. Some example files are d.gif, b.gif, db.gif, and dp-p.gif
I also have XML files that store the name of the image that I want to display. It doesn't return the .gif, it will simply return db and dp-p when I parse the XML file.
So for example, I parse an XML file, get a string of dp-p, and I know that is the image that I want to display.
So the way in general I've been calling images to draw is I will have an ImageView and set the icon based on the resource named R.id.<resource name>, and that variable will return an integer ID to the icon, and the draw function knows what to draw based on my ID.
So for instance, to draw the dp-p.gif I would call the image draw function and pass it R.id.dp-p and it would know which image to draw.
The problem I'm having is that since this is dynamically loaded from the value in the XML file, I am not sure how I can just kind of append the R.id. and the value in my XML string in order to pass it into the drawing function, since I'm trying to append an actual string to a variable name.
This is kind of hard for me to explain and I am not sure what to even google search for, but if anyone has any suggestions that would be great, thanks. If you have more questions about my explanation just ask and I will try to explain it better.