how to set imageview src?

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

    To set image cource in imageview you can use any of the following ways. First confirm your image is present in which format.

    If you have image in the form of bitmap then use

    imageview.setImageBitmap(bm);
    

    If you have image in the form of drawable then use

    imageview.setImageDrawable(drawable);
    

    If you have image in your resource example if image is present in drawable folder then use

    imageview.setImageResource(R.drawable.image);
    

    If you have path of image then use

    imageview.setImageURI(Uri.parse("pathofimage"));
    

提交回复
热议问题