how to set imageview src?

后端 未结 3 1044
梦如初夏
梦如初夏 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:24

    Each image has a resource-number, which is an integer. Pass this number to "setImageResource" and you should be ok.

    Check this link for further information:
    http://developer.android.com/guide/topics/resources/accessing-resources.html

    e.g.:

    imageView.setImageResource(R.drawable.myimage);
    

提交回复
热议问题