0
在GridView中使用Droidfu的小部件WebImageView創建圖庫。圖像是通過WebImageView異步下載並緩存的。Droidfu WebImageView和GridView問題
問題是,當網格滾動到它時,id並不總是顯示圖像(它顯示默認錯誤img)。這就像getView正在銷燬它,並且無法正確地回收它。
這是我GridAdapter
公共類GalleryAdapter延伸BaseAdapter {
private Context mContext;
public GalleryAdapter(Context c) {
// TODO Auto-generated constructor stub
mContext = c;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return theList.getItemCount();
}
@Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return theList.getItem(arg0);
}
@Override
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return arg0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
final GalleryItem galeryItem = theList.getItem(position);
if (convertView == null) {
convertView = (View) getLayoutInflater().inflate(R.layout.gallery_item, parent, false);
}
WebImageView imageView = (WebImageView) convertView.findViewById(R.id.webimage);
if (!galeryItem.getMain_image().trim().equalsIgnoreCase("")) {
imageView.setScaleType(ScaleType.CENTER_CROP);
imageView.setAdjustBounds(true);
imageView.reset();
imageView.setImageUrl(galeryItem.getMain_image().trim());
imageView.setNoImageDrawable(R.drawable.heading_img_bg);
imageView.loadImage();
}
TextView heading = (TextView) convertView.findViewById(R.id.gallery_heading);
heading.setText(galeryItem.getHeading());
TextView img_num = (TextView) convertView.findViewById(R.id.gallery_img_num);
img_num.setText(Integer.toString(galeryItem.getImage_num()));
return convertView;
}
}