android根据图片路径显示图片

首先根据图片路径先创建一个文件path为图片路径;然后判断文件是否存在,如果存在,将图片显示出来。

File file = new File(path);

ImageView img = (ImageView) findViewById(R.id.img);

if(file.exists()){

       Bitmap bm = BitmapFactory.decodeFile(path);

       img.setImageBitmap(bm);

}

posted on 2016-07-05 16:09  随缘101  阅读(4440)  评论(0编辑  收藏  举报