【发布时间】:2013-09-15 07:25:16
【问题描述】:
我正在尝试在 imageview 中显示图像。我知道可以通过在setImageBitmap()中传递图片路径来完成。
我已经做到了。由于一些内部问题,我的模拟器性能下降,因此我将模拟器从 Google 更改为 Intel x86。从那时起,我的与图像相关的应用程序无法正常工作。关于在 imageview 中显示图像有什么问题吗?
图片显示代码sn-p:
try
{
path = info.getPath(); //this variable contains the filename of the image.
File sdCardPath = Environment.getExternalStorageDirectory(); // code to get the path of the folder storing the image file
Bitmap bitmap = BitmapFactory.decodeFile(sdCardPath+"/DCIM/Camera/SAMPLE IMAGES/"+path);
jpgView.setImageBitmap(bitmap);
Toast.makeText(getApplicationContext(), "This is reg pic : "+sdCardPath+"/DCIM/Camera/SAMPLE IMAGES/"+path, Toast.LENGTH_SHORT).show(); }
catch(NullPointerException er)
{
String ht=er.toString();
Toast.makeText(getApplicationContext(), ht, Toast.LENGTH_SHORT).show();
}
图像文件存储方式如下 -
【问题讨论】:
-
如果遇到错误,请发布一些代码或 logcat
-
否@MetalHead,我在 logcat 中没有收到任何错误。我什至可以在 Toast 中获取该图像的路径。
标签: android android-emulator imageview android-imageview android-image