0

I have a ListView that contains images. This images load with UrlImageLoader. The problem is that the first row/item always loads the wrong image. It seems that the first item image loaded is the last image that UrlImageLoader has loaded. The process of load is, for example:

  • First item image: loads well.
  • Second item image: loads well.
  • Third item image: loads well.
  • Fourth item image: loads well, but also changes the first item image.

Edit:

Maybe the getView code will help you to find the problem.

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

0 に答える 0