我试图从外部存储装载图像。我设置了权限,我尝试了不同的方式,但都不起作用。从外部存储中读取图像/文件Android
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bitmap = BitmapFactory.decodeFile(file.toString());
tv.setImageBitmap(bitmap);
而这其中,
FileInputStream streamIn = new FileInputStream(file);
Bitmap bitmap = BitmapFactory.decodeStream(streamIn);
tv.setImageBitmap(bitmap);
streamIn.close();
什么是你的错误? – Zyerah 2013-04-10 06:17:01
上述代码中的电视是什么。它是一个文本视图? – Raghunandan 2013-04-10 06:32:11
我没有收到任何错误,因为我尝试了一下,但是如果没有它,应用程序就会崩溃。 ImageView tv =(ImageView)findViewById(R.id.imageView1); – 2013-04-10 06:41:35