How to set an imageView's image from a string?

前端 未结 4 890
北荒
北荒 2020-11-30 04:02

I have a list of entries and some bitmap files in the res/drawable-mdpi directory. I\'m trying to load the image corresponding to the string value selected from the list by

4条回答
  •  情深已故
    2020-11-30 04:33

    ImageView img = (ImageView) findViewById(R.id.{ImageView id});
    img.setImageResource(getResources().getIdentifier("ImageName","drawable",getPackageName()));
    

提交回复
热议问题