Issue
Possible Duplicate:
Access a resource name programmatically
I'm trying to set a drawable id with a string, but it doesn't work..
So i tried this:
String NoteString = "R.drawable.notebackground".toString();
remoteviews.setImageViewResource(R.id.backgroundImage, context.getResources().getIdentifier(NoteString, "drawable", "com.example.MY-PACKAGE-NAME"));
but the image doesn't appear.
if i say this it works:
remoteviews.setImageViewResource(R.id.backgroundImage, R.drawable.notebackground);
what's wrong?
Solution
remoteviews.setImageViewResource(R.id.backgroundImage, getResources().getIdentifier(imageFilename, "drawable", getPackageName()));
Answered By - Rawkode
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.