Skip to content Skip to sidebar Skip to footer

Android Listiem Recycle While Scroll Up Or Down

I am using complex list item as following to lazy upload image i am loading every list item's image in separate asyntask so that it won't hang the application while loading image.

Solution 1:

My understanding is that you use getView() method from your adapter to provide your own layout for list item. So probably you have something like this:

public View getView(int position, View convertView, ViewGroup parent) {

        if(null == convertView){
            convertView = mInflater.inflate(R.layout.row, null);
            //...               
        }
        //... setting new values for your widgetsreturn convertView
    }

If that is the case, then it is your call to recycle items. Such implementation prevents garbage collector to be called to often, but if it's not a problem and you can bear with GC, then you can just get rid of if(null==convertView) and construct your item from the scratch - every time getView method is invoked.

But probably that is not a good idea, it would be better if you retrieve your image widget from recycled item, set some temporary image and then start your async task to download the proper image. Regads!

Post a Comment for "Android Listiem Recycle While Scroll Up Or Down"