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;
}
}