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

    src="@drawable.norusdpyr"

in the Activity's XML file, the file displays fine.  BUT, if I put

    String imageresource = "R.drawable." + parsedData[4].toString();
    chart.setImageURI(Uri.parse(imageresource));

where parsedData[4].toString() = "nor_usdpyr" I don't see anything.
I've also tried

    String imageresource = "android.resource://" + getPackageName() +
"/R.drawable." + parsedData[4].toString();
    chart.setImageURI(Uri.parse(imageresource));

and

    InputStream is = getClass().getResourceAsStream("/drawable/" +
parsedData[4].toString());
    chart.setImageDrawable(Drawable.createFromStream(is, ""));

and

    String imageresource = "R.drawable." +
parsedData[4].toString();
    File file = new File(imageresource);
 
chart.setImageDrawable(Drawable.createFromPath(file.getAbsolutePath()));

and

    Context context = getApplicationContext();
    int ResID = context.getResources().getIdentifier(imageresource,
"drawable", "com.KnitCard.project");
    chart.setImageResource(ResID);

finally even,

    chart.setImageURI(Uri.parse("android.resource://" +
getPackageName() + "/R.drawable.nor_usdpyr"));

None of these work.  What am I doing wrong?  Thanks!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to