Should prefetched images still be lazy loaded into a ListView?
I'm populating a list of relatively complex list items including several textviews, a button, and an ImageView. The images associated with each item are unique but have been prefetched from the internet so I do not need to wait for an HTTP request to download the image.
Still, I am wondering if it would still be prudent to lazy load the images from memory so that the list can be displayed as quickly as possible. Android has this behavior in the manage applications list. It fills the list with generic data and corrects each item as better data becomes available.
How big of a performance issue is loading several images from memory into a listview (especially considering fast scrolling of large lists (300+ items))? What are the tradeoffs I need to consider?
It shouldn't be necessary to do any lazy loading yourself. A ListView
has lazy loading built in. It will only load the list view items that are currently visible on the page. It loads the later items in the list as you scroll.
In general, I would only try to optimize this if you actually experience performance problems. As it talks about in Designing for Performance,
There are two basic rules for writing efficient code:
Attempting to do your own pre-optimization of loading these images, without any benchmarks to indicate that you have a real problem would break both of those rules.
链接地址: http://www.djcxy.com/p/93120.html