Your question is very interesting, and there are some solutions. I just posted some solutions here with a link.
1. Cache of your data
When the user scrolls, your adapter will request some data from the array, from the database or network. Due to poor performance, I think maybe a problem, because the data load time is long. Therefore, the best way to solve this problem is to cache data.
You can cache your data in memory using the LRUCache class and on disk using DiskLRUCache. Android manual exists for this problem: Caching a bitmap image
Psuedo Code:
if (memoryCache.get(key)) { // load data from memory and assign to cell } else if (diskCache.get(key)) { // load data from disk and assign to cell } else { // get data from database or network // assign to cell // save to memory cache // save to disk cache }
2. Use a different thread to load data
When you handle a long-term task affecting your user interface, you should put it in the user interface thread and create a new thread for your purpose. You can use Asynctask for this purpose.
The problem with this method is this: when loading data from the background, the displayed cell on the screen using the scroll event needs different data. That way, when the old asynctask object completed, it assigns the old data to your cell. BUMP !!! . Therefore, you must carefully monitor the condition of your camera. There is a good tutorial: Loading a bootable image into another stream
3. Simplify the presentation
If you are not using something like database processing, a network query while scrolling, perhaps the problem is that your view is too complicated. You should use this tool: Hierarchy Viewer to check which layout file has performance issues. You can also use the GPU drag and drop tool to verify that many parts of your view have made many things unnecessary.
4. Determine the time for updating the database by frame rate
You should always keep the frame rate below 60 frames per second. With this frame rate, the user will not recognize lag, awkward ... in your opinion. You can use the GPU Profiler to check the frame rate. Based on this frame rate, you decide that you should simplify viewing, optimize the onDraw method onDraw or optimize your graphic design (due to overuse) to maintain a user interface frame rate of <= 60 frames per second.
All the above methods that I included in my project called ImageUploader . This application uploads an image to Flickr and displays a list of all uploaded images or views individual images.
Google has downloaded the Android Performance Pattern series to teach you many useful things, such as caching, dosing, useful tips ...
Hope this help :)