您可以使用此負載位圖:
ImageView imgInternal = (ImageView) findViewById(R.id.imgInternal);
ImageView imgExternal = (ImageView) findViewById(R.id.imgExternal);
String internal = context.getFilesDir().getAbsolutePath() + "/" + "img.png"; // For internal storage
String external = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + "img.png"; // For external storage
Bitmap bmpExternal = BitmapFactory.decodeFile(external); // For external
Bitmap bmpInternal = BitmapFactory.decodeFile(internal); // For internal
imgExternal.setImageBitmap(bmpExternal);
imgInternal.setImageBitmap(bmpInternal);
外部存儲,您應該添加這AndroidManifest.xml
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
BMP位圖= BitmapFactory。 decodeFile(外部); 位圖bmp = BitmapFactory.decodeFile(internal); 這是說「重複本地變量bmp」 – 2014-09-26 08:36:49
你必須選擇一個,內部或外部,如果你想使用兩個內存,你應該改變一個位圖變量的名稱。我正在編輯我的答案。 – RdlP 2014-09-26 08:38:52
但是從一個imageview我不能得到兩個選項? PH存儲器和SD卡存儲器選擇任何一個。 – 2014-09-26 08:42:12