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擁有此權限 –