Show Image View from file path?

前端 未结 13 728
眼角桃花
眼角桃花 2020-11-22 11:18

I need to show an image by using the file name only, not from the resource id.

ImageView imgView = new ImageView(this);
imgView.setBackgroundResource(R.drawa         


        
相关标签:
13条回答
  • 2020-11-22 11:51

    You can use:

    ImageView imgView = new ImageView(this);
    InputStream is = getClass().getResourceAsStream("/drawable/" + fileName);
    imgView.setImageDrawable(Drawable.createFromStream(is, ""));
    
    0 讨论(0)
提交回复
热议问题