2017-04-07 11 views
-3

在jsone沒有價值,我收到:遠程圖像未加載。對於profilePic JSONException

"profilePic":"http:\/\/api.androidhive.info\/feed\/img\/nat.jpg","image":"\/images\/1491410855.JPG"

如何使用setImageUrl()它轉換成普通URL在ImageView的設置?

+0

你應該使用一個庫如畢加索上設置的圖像imageview – Eenvincible

+0

那我是一個正常的URL與轉義字符...修復生成該JSON的服務器 –

+0

我曾嘗試使用'.replaceAll(「\\\\」,「」)''它對我有用。 –

回答

0

但是,由於您看到轉義字符,因此您會打印/收集JSON不正確。

例如,這source

{ 
    "feed": [ 
     { 
      "id": 1, 
      "name": "National Geographic Channel", 
      "image": "http://api.androidhive.info/feed/img/cosmos.jpg", 
      "status": "\"Science is a beautiful and emotional human endeavor,\" says Brannon Braga, executive producer and director. \"And Cosmos is all about making science an experience.\"", 
      "profilePic": "http://api.androidhive.info/feed/img/nat.jpg", 
      "timeStamp": "1403375851930", 
      "url": null 
     }, 

嘗試使用凌空JsonObjectRequest

然後,

JSONArray feed = response.getJSONArray("feed"); 
for (int i = 0; i < feed.length(); i++) { 
    JSONObject feedObj = feed.getJSONObjet(i); 
    String profilePic = feedObj.getString("profilePic"); 
    // Picasso.load(profilePic).into(imageView); // for example 
} 

See tutorial