Here你可以找到一個延遲加載庫來從URL下載圖像,並顯示在一個ListView
。此外,我建議你避免使用3個不同的Arraylists
,而只使用一個ArrayList
,而用一個用於存儲圖像信息(標題,日期和圖像url)的自定義類。
編輯:下面是一個例子類,用於保存所需圖像的信息:
import java.util.Date;
public class ImageObject {
private String image_name;
private String image_url;
private Date image_date;
public ImageObject() {
}
public ImageObject(String image_name, String image_url, Date image_date) {
this.image_name = image_name;
this.image_url = image_url;
this.image_date = image_date;
}
public void setImageName(String image_name) {
this.image_name = image_name;
}
public void setImageURL(String image_url) {
this.image_url = image_url;
}
public void setImageDate(Date image_date) {
this.image_date = image_date;
}
public String getImageName() {
return this.image_name;
}
public String getImageURL() {
return this.image_url;
}
public Date getImageDate() {
return this.image_date;
}
}
下面是在女巫的示例用法我發起ArrayList
與一個ImageObject
:
ArrayList<ImageObject> data = new ArrayList<ImageObject>();
ImageObject obj = new ImageObject("test.jpg", "www.imageurl.com", new Date());
data.add(obj);
這就是如何從某個ImageObject
對象中檢索一個值:ArrayList
:
data.get(0).getImageName();
檢查此[SO](http://stackoverflow.com/questions/12161137/android-download-image-from-url-and-show-in-imageview) –
嘗試此http:/ /stackoverflow.com/a/16560535/1911784 – OMAK
對於listview使用懶加載http://stackoverflow.com/questions/541966/how-do-i-do-a-lazy-load-of-images-in-listview –