mellomel70
Lurker
I have a png file in my res/drawable-ldpi folder. I'm working in Eclipse with the emulator, but I've tried this on my 2.2.1 Android phone and I get the same behavior. I have an ImageView and I want to set the src programatically, based on a database call. If I just put
in the Activity's XML file, the file displays fine. BUT, if I put
where parsedData[4].toString() = "nor_usdpyr" I don't see anything. I've also tried
and
and
and
finally,
doesn't work.
None of these work. What am I doing wrong? Thanks!
Code:
src="@drawable.norusdpyr"
Code:
String imageresource = "R.drawable." + parsedData[4].toString();
chart.setImageURI(Uri.parse(imageresource));
Code:
String imageresource = "android.resource://" + getPackageName() + "/R.drawable." + parsedData[4].toString();
chart.setImageURI(Uri.parse(imageresource));
Code:
InputStream is = getClass().getResourceAsStream("/drawable/" + parsedData[4].toString());
chart.setImageDrawable(Drawable.createFromStream(is, ""));
Code:
String imageresource = "R.drawable." + parsedData[4].toString();
File file = new File(imageresource);
chart.setImageDrawable(Drawable.createFromPath(file.getAbsolutePath()));
Code:
Context context = getApplicationContext();
int ResID = context.getResources().getIdentifier(imageresource, "drawable", "com.KnitCard.project");
chart.setImageResource(ResID);
Code:
chart.setImageURI(Uri.parse("android.resource://" + getPackageName() + "/R.drawable.nor_usdpyr"));
None of these work. What am I doing wrong? Thanks!