"Android" ListView, Recyclerview asynchronous loading picture causes dislocation problem

Source: Internet
Author: User

Today in the Recyclerview table encountered a situation, it contains 300 data, each containing a picture, found in the first load, because the local no map, when the request network, the rapid slide caused the picture dislocation, flashing problems.

Principle of the words have been said very clearly, we can refer to the following

The following is a talk about the actual use, is how to solve the problem of dislocation.

The general dislocation occurs on a time-consuming HTTP request, so for each picture request

Before initiating

1: The picture is preset to a local placeholder picture first. Important A lot of dislocation is the reuse of other locations of the image cache, and the current picture is not loaded, resulting in the current picture dislocation. So the solution is to use a local placeholder image to quickly refresh the current picture. After loading, you can replace the placeholder image. )

2: Through Imageview.settag, the URL is recorded inside the picture.

3: Put the URL into a request queue (this is to avoid a large picture, the request takes a long time, repeatedly initiating a URL request)

Initiated in

1: If the request queue has a URL, it returns

After initiating

If the current URL is the same as the first step Imageview.gettag, the picture is updated with the new data source.

otherwise returned.

If the picture is reused, it is best to write to the local store after the visit, avoiding time consuming network requests.

"Android" ListView, Recyclerview asynchronous loading picture causes dislocation problem

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.