Android ListView Asynchronous loading Picture dislocation, repetition, flicker analysis and solutions

Source: Internet
Author: User

When we use the ListView to load images asynchronously, in the case of fast sliding or bad network, there will be picture dislocation, repetition, flicker and other problems, in fact, these problems summed up is a problem,

For example, there are 100 item on the ListView, one screen shows only 10 item, we know that GetView () Converview is used to reuse the view object, because an item's view object, And the ImageView control is the view through the Findviewbyid (), and when we re-use the View object, that is, the ImageView is also reused, such as the 11th item view of the first Itemv Iew object, Then the ImageView is reused at the same time, and the display picture is through the ImageView control, so when the picture is not downloaded, the data displayed on this imageview is the data that is reused

1:item picture Display repeat?

This display repetition means that the current line item shows a picture of the previous line item

For example, the ListView slides to the 2nd row to load a picture asynchronously, but the load is slow, the ListView has slid to line 14th during the loading process, and the picture is loaded at the end of the slide.
Line 2nd is no longer in the screen, according to the caching principle described above, the 2nd line of view may be reused in line 14th, so we see that the 14th line shows the image that should belong to the 2nd line, resulting in duplicate display


Line item picture shows confusion?
This display disorder refers to a line item that shows a picture that does not belong to the line item.
For example, the ListView slides to the 2nd row to load a picture asynchronously, but the load is slow, the ListView has slid to line 14th in the loading process, line 2nd is no longer in the screen,
According to the caching principle described above, the 2nd line of view may be re-used in line 14th, the 14th line shows the 2nd row of view, then the previous picture loading end, will be displayed in the 14th line, causing confusion


The line item picture shows flashing?
In the case of the above B, the 14th line of the picture again quickly loaded the end, so we see the 14th line first shows the image of line 2nd, and immediately display their own pictures to cover the flickering confusion


Solution:

Through the above analysis we know that the cause of the disorder is the asynchronous loading and the object is reused, if each time

GetView

can give an identity to an object,

Compare identity with current row when asynchronous loading is complete

Item

The identity is consistent,

One

To be displayed, otherwise it will not be processed

Through the above analysis we know that the cause of the disorder is the asynchronous loading and the object is reused, if each time

GetView

can give an identity to an object,

Compare identity with current row when asynchronous loading is complete

Item

The identity is consistent,

One

To be displayed, otherwise it will not be processed

Through the above analysis we know that the cause of the disorder is the asynchronous loading and the object is reused, if each time GetView can give an identity to the object, when the asynchronous loading is done to compare the identity with the current row of the identity of the item is consistent, the same is displayed, otherwise do not do processing can


Principle: First give ImageView set a tag, this tag is set in the URL, and then at the time of loading to get this URL and to load that position in the URL comparison, if not the same load, the same is reused before the load

Android ListView Asynchronous loading Picture dislocation, repetition, flicker analysis and solutions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.