Issue
In my Widget
i have one ImageView
, i will receive a code from out side ,these codes are between 1-40 , from other side i have 40 different images in my drawable
folder which i named them the same as their related code.
now what I want to do it ,by reading one code from outside, show the image which has the same name in the ImageView
.
for example if i read the code 33, i want to show the image which named 33 in the ImageVIew
.
Solution
put your images in assets folder and you will be able to pick image by name. suppose your text is 33 and your image name is 33.png
AssetManager assetManager = context.getAssets();
String fileName = "33";
Bitmap b = BitmapFactory.decodeStream(assetManager.open(fileName + ".png"));
imageView.setImageBitmap(b);
Answered By - Ali
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.