how to set imageview src?

后端 未结 3 1057
梦如初夏
梦如初夏 2021-02-02 07:15

I have an image view and a string src. I want to set the imageview source to the string src that I have, but am unable to do so beacuse the method expects an i

3条回答
  •  时光说笑
    2021-02-02 07:26

    What you are looking for is probably this:

    ImageView myImageView;
    myImageView = mDialog.findViewById(R.id.image_id);
    String src = "imageFileName"
    
    int drawableId = this.getResources().getIdentifier(src, "drawable", context.getPackageName())
    popupImageView.setImageResource(drawableId);
    

    Let me know if this was helpful :)

提交回复
热议问题