Using setImageDrawable dynamically to set image in an ImageView

前端 未结 17 1805
借酒劲吻你
借酒劲吻你 2020-12-04 08:22

I am generating a string from database dynamically which has the same name of image in drawable folder.

Now I want to set that value for ImageView

17条回答
  •  萌比男神i
    2020-12-04 09:01

    I had the same problem as you and I did the following to solve it:

    **IMAGEVIEW**.setImageResource(getActivity()
                 .getResources()
                 .getIdentifier("**IMG**", "drawable", getActivity()
                 .getPackageName()));
    

提交回复
热议问题