我試圖從外部存儲裝載圖像。我設置了權限,我嘗試了不同的方式,但都不起作用。從外部存儲中讀取圖像/文件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