2016-05-09 143 views
1

希望你做得很好,我正在一個應用程序,因爲我想從url加載圖像到一個imageView,我已經使用畢加索lib這個,但它給?我未捕獲的異常,我已經檢查和調試的是正確的網址是來還是不來和它完美的,不過我面對這個問題,任何人可以幫助我解決這個我的代碼如下: 代碼無法加載圖像在Android使用畢加索圖書館

Picasso.with(NewProfileActivity.this) 
         .load(mUser.userAvatarPath) 
         .into(iv_profile); 

這裏「iv_profile」是imageView,mUser.userAvatar路徑是圖片url。

+1

包含錯誤 –

+0

@TimCastelijns - 它的uncaughtException。 –

+0

這並不意味着很多。包括堆棧跟蹤 –

回答

6

試試這個

Picasso.with(this).load("http://api.androidhive.info/json/movies/1.jpg").placeholder(getResources().getDrawable(R.drawable.ic_launcher)).into(imageViewCenter); 
+1

@ monty-perfect ...謝謝兄弟 –

-2

使用此代碼的工作,你的情況

Picasso.with(mContext).load(Imagename.png).fit().centerCrop().error(R.mipmap.ic_profile).fit().placeholder(R.mipmap.ic_profile).fit().into(imgNDProfile); 
+0

不工作... !!! –

+0

可能是你的代碼在其他地方發現錯誤,可能是你的圖片名稱有大寫字母或其他問題檢查我們的代碼人.. –

0

試試這個,

Picasso.with(context) 
.load(url) 
.placeholder(R.drawable.user_placeholder) 
.error(R.drawable.user_placeholder_error) 
.into(imageView); 

佔位幫助沒有加載你的原始URL時。

,並把

​​

您的manifest.xml

這可能幫助你。

2
Picasso.with(this).load("http://city/1.jpg").placeholder(getResources().getDrawable(R.drawable.ic_city)).into(imageViewCity); 
0

請檢查您的圖片網址,如果它不包含http://前綴則圖片將不會被加載。確保圖片網址的前綴爲http://