The GridView Fuchscassida Adapter Way
If you only use the GridView Fuchscassida adapter method, because loading the picture takes time, if you load the image directly in the GetView, it will affect the UI, as the sliding time lag. So, every time we load a picture, we start an extra process so that it doesn't affect the main thread of the UI.
Just opening an extra thread will cause a "disorderly order" problem. That is, the "concurrency" problem.
Because, when you are sliding, the area that passes through will open the line loads load picture, each thread executes the time that completes is not fixed. The current screen is displayed only when the thread has finished executing. As a result, when you are sliding on a large scale, some areas of the picture are not shown and are being slid away, but their threads are still there and all the threads are squeezed to the current screen display. So the pictures that have been slid will be displayed in a continuation, often a position to display several different pictures (because the line preempted the time difference between each other), and finally shown as the screen original picture.
This is the problem of concurrency, where two or more events occur at the same time interval.
This should enable you to understand why concurrency problems occur because there are multiple threads executing at the same time, and we cannot guarantee that the thread of the picture will stop executing after it has been slid.
To solve the concurrency problem, there are two ways I've tried recently, one recommended on Android docs, and one that looks at the Guolin of the Great God Blog.
Recommended Way on Android doc
Android Doc recommended method, the idea is to bind the thread with each location (ImageView), before the picture is not loaded with a stand picture, if the executing thread is not the current picture of the bound thread is canceled, no longer loaded. This allows only the thread that is bound to execute, and does not repeat multiple different pictures in one place.
Reference Links:
Http://developer.android.com/training/displaying-bitmaps/process-bitmap.html
Guolin the Settag Way of the Great God
and guolin the great God with a Imageview.settag (Imgeuri), for each location binding a picture, where Imageuri is the local storage path for each picture, can be guaranteed not to repeat, you can also use it to load pictures.
Reference Link: http://blog.csdn.net/guolin_blog/article/details/9526203
So I tried to write it myself with Settag (), which really solved the problem. However, the speed of the picture is much slower than the Guolin, which is much slower than the Android Doc. Think about it, it turns out that the method of Android Doc is after the judgment has canceled the execution of the thread. And I'm just after the thread executes, to determine whether the picture loaded by it is bound to that location. No bindings are displayed. In this way, all threads, no matter how useful, are executed once and are inefficient. And Guolin is not the same as the great God, because he rewrote the Onscoll (), when the sliding, all the threads are canceled, only the time to stop the thread, so there will not be useless threads in the execution. I think this is also very good!
This article is from "What is a blog title?" "Blog, be sure to keep this provenance http://ysc921003.blog.51cto.com/5786498/1574182
Android Image Display (i) ———— about concurrency, the handling of disorder problems