Android ListView uses soft references to fix load network pictures fast sliding stutter

Source: Internet
Author: User

A period of time to do a news project, the news list of pictures are network pictures, just start is a custom ImageView (and so in which added an asynchronous download and then set the background) although the network image can be loaded, but when the fast sliding will be very lag, and the early stage of the bitmap do not recycle , resulting in oom (memory overflow), and later on the internet to look up a variety of information, there are probably two ways:

1. When sliding, do not load the picture, wait for the slide to stop and then load, so the ListView needs to be onscrolllistener monitored, Get the start and end of the screen display (when there are headview and Footerview need to convert) and then download the corresponding network picture, each download one on the adapter for notifydatasetchanged operation, disadvantage: The code is relatively large, There is the sliding and not sliding need to use the lock to control, although according to this idea to achieve, but feel more trouble, not reliable;

2. Is the use of soft references, not much nonsense,:

Source: http://www.eoeandroid.com/thread-589993-1-1.html

Android ListView uses soft references to fix load network pictures fast sliding stutter

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.