我想要添加到ListView的有關部件:如何在listview中使用Picasso?
public class Widget {
String w_type;
String title;
String desc;
String img;
//....
}
我想表明在列表視圖圖像,如果IMG字段不爲空。我應該如何使用Picasso而不用在滾動後重覆在ListView中顯示錯誤圖像的Ang?這是從我的適配器的列表視圖的getView方法的當前代碼:
public View getView(int i, View someView, ViewGroup arg2) {
LayoutInflater inflater = LayoutInflater.from(context);
if (someView == null) {
someView = inflater.inflate(R.layout.widgets_list, arg2, false);
}
ImageView img = (ImageView) someView.findViewById(R.id.pic);
String img_url = data.get(i).img;
if (!img_url.equals("")){
Picasso.with(context).load(img_url).into(img);
}
return someView;
}
但現在ListView顯示錯誤和重複的圖像。我該如何解決它?
實施'ViewHolder'在'getView()'方法。對於更詳細地訪問此:http://stackoverflow.com/questions/23120238/using-picasso-library -with-listview – Ironman