android - 按文件名显示图像

标签 android imageview

我需要通过指定文件名而不是使用资源来显示图像。例如 showImage("background.png") 而不是 showImage(R.drawable.background)

有人知道吗?

非常感谢。

最佳答案

阅读此 Android Image Tutorial .有一个使用 FileOutputStream 写入图像的示例,我相信也有 FileInputStream。这是 another code example下载图像并将它们转换为已解码的输入流:

bmImg = BitmapFactory.decodeStream(is);
imView.setImageBitmap(bmImg);

关于android - 按文件名显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/587454/

相关文章:

android - 首次安装后应用程序屏幕变为空白(无法从设备中获取文件夹)

android - 在android中的ImageView上方画一条线

android - 如何在 imageview android 中显示大尺寸位图?

Android Picasso 处理方向改变

android - 通过android应用程序将数据写入firebase

android - gradle:根据构建类型(或变体)执行代码

java - 通知启动时出现 NullPointerException

java - 推送或拉取通知

android - 在 android 中,我可以将 subview 添加到 ImageView 吗?

android - 在 Android 中从 json 中的 url 下载并显示图像