我有一个ListView
包含图像的。此图像使用UrlImageLoader
. 问题是第一行/项目总是加载错误的图像。似乎加载的第一个项目图像是 UrlImageLoader 加载的最后一个图像。加载过程例如:
- 第一项图片:加载良好。
- 第二项图片:加载良好。
- 第三项图片:加载良好。
- 第四项图像:加载良好,但也更改了第一项图像。
编辑:
也许 getView 代码会帮助您找到问题所在。
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ChannelMainGuideViewHoler channelMainGuideViewHolder;
try {
// LIST CHANNEL CASE (SLIDE 3)
if ( convertView == null || convertView.getTag() == null) {
convertView = mInflater.inflate(this.layout, null);
channelMainGuideViewHolder = new ChannelMainGuideViewHoler();
channelMainGuideViewHolder.title1 = (TextView) convertView.findViewById(R.id.title1);
channelMainGuideViewHolder.title2 = (TextView) convertView.findViewById(R.id.title2);
channelMainGuideViewHolder.image1 = (ImageView) convertView.findViewById(R.id.image1);
channelMainGuideViewHolder.image2 = (ImageView) convertView.findViewById(R.id.image2);
channelMainGuideViewHolder.button1 = (ImageView) convertView.findViewById(R.id.button1);
convertView.setTag(channelMainGuideViewHolder);
} else {
channelMainGuideViewHolder = (ChannelMainGuideViewHoler) convertView.getTag();
}
// Item
ListViewItems item = items.get(position);
if (item != null) {
channelMainGuideViewHolder.title1.setTag(item);
channelMainGuideViewHolder.title1.setText(item.getItemTitle());
channelMainGuideViewHolder.title2.setText(item.getItemTitle2());
UrlImageLoader.setUrlDrawable(channelMainGuideViewHolder.image1,item.getItemImage());
channelMainGuideViewHolder.image1.setImageDrawable(item.getItemDrawable());
UrlImageLoader.setUrlDrawable(channelMainGuideViewHolder.image2,item.getItemImage2());
channelMainGuideViewHolder.button1.setTag("next");
channelMainGuideViewHolder.button1.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
if(((String)view.getTag()).equals("next")){
channelMainGuideViewHolder.button1.setTag("previous");
((ImageView)view).setImageResource(R.drawable.previous);
ListViewItems item = (ListViewItems)channelMainGuideViewHolder.title1.getTag();
channelMainGuideViewHolder.title1.setText(item.getItemTitleNext());
channelMainGuideViewHolder.title2.setText(item.getItemTitle2Next());
UrlImageLoader.setUrlDrawable(channelMainGuideViewHolder.image2, item.getItemImage2Next());
} else {
channelMainGuideViewHolder.button1.setTag("next");
((ImageView)view).setImageResource(R.drawable.next);
ListViewItems item = (ListViewItems)channelMainGuideViewHolder.title1.getTag();
channelMainGuideViewHolder.title1.setText(item.getItemTitle());
channelMainGuideViewHolder.title2.setText(item.getItemTitle2());
UrlImageLoader.setUrlDrawable(channelMainGuideViewHolder.image2,item.getItemImage2());
}
}
});
}
return convertView;
} catch (Exception e) {
e.printStackTrace();
}
return convertView;
}