Question

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.

problem comes when i scroll down the list new lisitems image had replace image effect when i drill down i found that

for example if by default 5 listitems fit onto the screen when i scroll down next displayed listem is actually the recycle of the previous listitem which was displaying thats why also containing the image of the previous listitem untill new image loaded, after new image loaded from web image get replaced and user found replace image effect when doing scroll up or scroll down every time images are getting replaced due to recycling...

Is there a way i can ask android to do not recycle the listitem when i scroll down or up so that it will not have replace image effect.

any good suggestion is appriciated

alt text http://www.freeimagehosting.net/uploads/8237cbd584.jpg

Was it helpful?

Solution

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 widgets
        return 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!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top