Imageview Overlap When Adding More Items In Existing Listview
Solution 1:
I suspect that your imageDownloader
is calling setImageResource
(or equivalent--it's setting the src
attribute) of your ImageView
, while you are initially calling setBackgroundResource
. That would explain the overlap.
What you need to do is change setBackgroundResource
to setImageResource
in the following code:
if(data.getTemplateIconId()!=0 && data.getTemplateIconUrl()==null ){
Log.d("Load icon ","Default Load");
// This line should say setImageResource:
holder.templateIcon.setBackgroundResource(data.getTemplateIconId());
} else ...
The issue that @Akos mentions (which he appears to have deleted) will be an issue for you if a download takes a long time and the view has already been reused. To restate what he stated, once you get this working via the solution above, you will find that if an image download takes a long time (so long that the row has already been reused, and the new image set) that your images may be overwritten with older images.
Therefore, inside of imageDownloader
you will also want to say, before downloading:
imageView.setTag(url);
and then after the download completes, before setting the image in the ImageView
:
if(!(String)imageView.getTag().equals(url)
{
return;
}
This way, if the ImageView
has been reused by another row in the meantime, the download will simply abort.
Post a Comment for "Imageview Overlap When Adding More Items In Existing Listview"