Android Listvitem AsyncTask Listitem Image Dereference

- 1 answer

I am using listview to display data, inside listview i am using image in every listeitem.

following method is called from wrapper class

public View getView(int position, View convertView,
    ViewGroup parent) {  /*implementation*/ }

I am following this tutorial

class DownloadImage extends AsyncTask<ImageView, Void, Drawable>{
        private ImageView iv;

        protected Drawable doInBackground(ImageView... params) {
            iv = params[0];
            return Util.getImageFromURL(imageURL); 

        protected void onPostExecute( Drawable d ) {

new DownloadImage().execute(getImageIcon());

getImageIcon contains the reference of the inflater layout's imageview.

Now problem is first when 2nd listeitem image gets loaded it also resplaces the first listeitem image and so on...

i think it is listitem's referencing issue but above code should work b/c i am passing imageview reference inside.



This blog post may provide some guidance on using images with ListViews.

EDIT: Since @Hunt has pointed out the above link is dead, here's a great one that is in the official Android developer docs: