0

我正在開發一個android應用程序。我需要從Java服務器加載圖像到Android Recyclerview或Listview。圖片加載從java服務器到android列表視圖

我通過這個線程瞭解東西的android側http://www.androidhive.info/2014/06/android-facebook-like-custom-listview-feed-using-volley/

我需要Java服務器端的幫助。我需要通過JSON數組來檢索圖像。這樣

{ 
    "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 
    }, 
    { 
     "id": 2, 
     "name": "TIME", 
     "image": "http://api.androidhive.info/feed/img/time_best.jpg", 
     "status": "30 years of Cirque du Soleil's best photos", 
     "profilePic": "http://api.androidhive.info/feed/img/time.png", 
     "timeStamp": "1403375851930", 
     "url": "http://ti.me/1qW8MLB" 
    }, 
    { 
     "id": 5, 
     "name": "Abraham Lincoln", 
     "image": null, 
     "status": "That some achieve great success, is proof to all that others can achieve it as well", 
     "profilePic": "http://api.androidhive.info/feed/img/lincoln.jpg", 
     "timeStamp": "1403375851930", 
     "url": null 
    }, 
    { 
     "id": 3, 
     "name": "Discovery", 
     "image": "http://api.androidhive.info/feed/img/discovery_mos.jpg", 
     "status": "A team of Austrian scientists has developed a laser system that causes fruit flies to dance.", 
     "profilePic": "http://api.androidhive.info/feed/img/discovery.jpg", 
     "timeStamp": "1403375851930", 
     "url": "http://dsc.tv/xmMxD" 
    }, 
    { 
     "id": 4, 
     "name": "Ravi Tamada", 
     "image": "http://api.androidhive.info/feed/img/nav_drawer.jpg", 
     "status": "Android Sliding Menu using Navigation Drawer", 
     "profilePic": "http://api.androidhive.info/feed/img/ravi_tamada.jpg", 
     "timeStamp": "1403375851930", 
     "url": "http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/" 
    }, 
    { 
     "id": 6, 
     "name": "KTM", 
     "image": "http://api.androidhive.info/feed/img/ktm_1290.jpg", 
     "status": "\"The Beast\" KTM 1290 Super Duke", 
     "profilePic": "http://api.androidhive.info/feed/img/ktm.png", 
     "timeStamp": "1403375851930", 
     "url": "" 
    }, 
    { 
     "id": 7, 
     "name": "Harley-Davidson", 
     "image": "http://api.androidhive.info/feed/img/harley_bike.jpg", 
     "status": "We’re assembling riders of every style, bike, and passion. If you ride with conviction, ride with us. You have 24 days to get ready for World Ride. Prepare by visiting:", 
     "profilePic": "http://api.androidhive.info/feed/img/harley.jpg", 
     "timeStamp": "1403375851930", 
     "url": "http://bit.ly/1wmBWaN" 
    }, 
    { 
     "id": 8, 
     "name": "Rock & Girl", 
     "image": "http://api.androidhive.info/feed/img/rock.jpg", 
     "status": "A long time back...", 
     "profilePic": "http://api.androidhive.info/feed/img/rock_girl.jpg", 
     "timeStamp": "1403375851930", 
     "url": "" 
    }, 
    { 
     "id": 8, 
     "name": "Gandhi", 
     "image": null, 
     "status": "An eye for an eye will make the whole world blind.", 
     "profilePic": "http://api.androidhive.info/feed/img/gandhi.jpg", 
     "timeStamp": "1403375851930", 
     "url": "" 
    }, 
    { 
     "id": 9, 
     "name": "LIFE", 
     "image": "http://api.androidhive.info/feed/img/life_photo.jpg", 
     "status": "In 1965, LIFE photographer Bill Ray spent weeks with the Hells Angels, but his amazing photos never ran in the magazine", 
     "profilePic": "http://api.androidhive.info/feed/img/life.jpg", 
     "timeStamp": "1403375851930", 
     "url": "http://ti.me/1rfcQa4" 
    }, 
    { 
     "id": 10, 
     "name": "Shakira", 
     "image": "http://api.androidhive.info/feed/img/shakira_la_la.png", 
     "status": "Download La La La (Brazil 2014) from iTunes:", 
     "profilePic": "http://api.androidhive.info/feed/img/shakira.jpg", 
     "timeStamp": "1403375851930", 
     "url": "http://smarturl.it/FWCalbum?IQid=sh" 
    }, 
    { 
     "id": 11, 
     "name": "A. R. rahman", 
     "image": "http://api.androidhive.info/feed/img/ar_bw.jpg", 
     "status": "", 
     "profilePic": "http://api.androidhive.info/feed/img/ar.jpg", 
     "timeStamp": "1403375851930", 
     "url": "" 
    } 
] 
} 

以及如何從服務器端獲取中的圖片網址這樣 enter image description here

+0

這可能有助於你https://github.com/nostra13/Android-Universal-Image-Loader –

+0

我需要開發一個java服務器端代碼以及如何獲取服務器映像路徑? – Arya

+0

意味着你的問題是如何寫一個web服務? –

回答

0

您可以使用畢加索庫。

Picasso.with(context).load(「http://api.androidhive.info/feed/img/cosmos.jpg」).placeholder(R.drawable.no_image).into(imageView);

+0

我正在獲取android側代碼。我需要在服務器端開發代碼。如何在java服務器中獲取像http://api.androidhive.info/feed/img/cosmos.jpg這樣的網址 – Arya

+0

您好Arya,您在獲取服務器映像路徑時存在問題,然後將映像服務器路徑存儲在您的數據庫中並返回它進入webservice –

+0

是的。我怎樣才能獲得服務器映像路徑? – Arya

相關問題