2017-01-01 82 views
0

我试图显示和附加图像存储在SD卡上的图像视图,我可以显示图像与setImageBitmap没有任何问题,但当我尝试使用Picasso不显示图像Andorid Picasso不显示图像从SDCARD

final File imageFile = new File(APP.DIR_APP + APP.IMAGE + "/" + channel.get(position).getFileName()); 
    if (imageFile.isFile() && imageFile.exists()) { 
     BitmapFactory.Options options = new BitmapFactory.Options(); 
     //options.inSampleSize = 8; 
     //holder.post_image.setImageBitmap(BitmapFactory.decodeFile(imageFile.getAbsolutePath(), options)); 
     Picasso.with(context).load(imageFile).into(holder.post_image); 
    } 
+0

指这样的:http://stackoverflow.com/a/24097624/5425930 –

+0

尝试'Picasso.with(上下文).load(Uri.parse(镜像文件)的ToString ())。(holder.post_image);' – Enzokie

+0

当毕加索失败时,如果图像尺寸真的很大,我也有类似的情况。对我而言,解决方案是迁移到Glide。 –

回答

0

我的代码是正确的,但是当我使用wrap_content时f或宽度和ImageView的高度,我没有看到图像

0
  1. 登录您的imageFile路径,并检查它。
  2. 检查要传递到Picasso.with(context)
  3. 如果一切正常的context,chanege您的代码:

    if (imageFile.isFile() && imageFile.exists()) { 
        Picasso.with(context).load(Uri.fromFile(imageFile)).into(holder.post_image); 
    } 
    
1

检查,如果你已经添加读取权限,如果你没有那么在清单文件中添加此行

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> 
+0

applicaton拥有此权限 –