My problem is when the user scrolls through the ListView. I looked around and saw numerous examples of the “lazy image of the list”, also watched a video on Google IO that talks about “good practice” to make this work. But my problem continues when the user moves up and down the ListView.
It happens that when scrolling through the list of images uploaded to each element are shuffled, and the avatar of each element next to the next element ends. I do not know if I am clear, but I will show with the image.
When you start, elements that do not have an image with a standard image.
Image 1: http://boxandroid.com/app/weguide/itsok.png Before scrolling through a custom ListView: http://boxandroid.com/app/weguide/nook.png
Please note that the images have been shuffled between other elements.
in my adapter:
public View getView(int position, View convertView, ViewGroup parent){ ViewHolder viewHolder = new ViewHolder(); if(convertView == null){ convertView = _inflate.inflate(R.layout.layout_list, null); viewHolder.text = (TextView) convertView.findViewById(R.id.title); viewHolder.owner = (TextView) convertView.findViewById(R.id.owner); viewHolder.image = (ImageView) convertView.findViewById(R.id.thumb); convertView.setTag(viewHolder); }else{ viewHolder = (ViewHolder) convertView.getTag(); } HashMap<String, String> item = (HashMap<String, String>) getItem(position); viewHolder.text.setText( item.get("poiName").toString() ); viewHolder.owner.setText( item.get("owner").toString() ); ImageView imageView = viewHolder.image; imageView.setTag(item.get("thumbs")); if(!item.get("thumbs").equals("null")){ Drawable cacheImage = loader.loadDrawable(item.get("thumbs"), new ImageManage.ImageCallback() { public void imageLoaded(Drawable imageDrawable, String imageUrl) { ImageView imageViewByTag = (ImageView) _listView.findViewWithTag(imageUrl); if(imageViewByTag != null) imageViewByTag.setBackgroundDrawable(imageDrawable); } }); imageView.setImageDrawable(cacheImage); notifyDataSetChanged(); } return convertView; }
android listview scroll lazy-loading
Aderbal nunes
source share