java - Calling a Drawable-Resource by a String -
so, let me explain default situation @ first: user can choose picture - , picture saved string (e.g. "picture1") in properties-file. wan't display picture loading string off properties-file , getting image out of drawables-resources r.drawable.mypicture.
this worked out:
string iconsstring[] = {"default", "icon"}; int iconsresource[] = {r.drawable.default, r.drawable.icon}; int iconresourceposition; int iconsstringlength = iconsstring.length; (int = 0; < iconsstringlength; i++) { if (iconsstring[i] == mproperties.getproperty("icon")) { iconresourceposition = i; } else { iconresourceposition = 0; } } btn_profileicon.setbackgrounddrawable(iconsresource[iconresourceposition]);
but doesn't work, since ".setbackgrounddrawable" not accept int-values. well, , that's i'm stuck. make "iconsresource[]" beeing "drawable" instead of "int", cause other problem :|
thanks help!
mmmm don't want this:
btn_profileicon.setbackgroundresource(iconsresource[iconresourceposition]);
Comments
Post a Comment