在 android ListView 中随机刷新缩略图

Randomly refreshing thumb in android ListView

我正在基于 http://javatechig.com/video/json-feed-reader-in-android 的 material 构建我的第一个应用程序。 到目前为止一切都很顺利,但缩略图有一个错误。当我滚动列表时,随机拇指图像快速 "refresh" 随机不同的拇指并返回原始图像。有什么建议为什么会这样吗?

您应该看看以下页面: http://developer.android.com/training/displaying-bitmaps/process-bitmap.html

处理并发部分解释了一切:

Common view components such as ListView and GridView introduce another issue when used in conjunction with the AsyncTask as demonstrated in the previous section. In order to be efficient with memory, these components recycle child views as the user scrolls. If each child view triggers an AsyncTask, there is no guarantee that when it completes, the associated view has not already been recycled for use in another child view. Furthermore, there is no guarantee that the order in which asynchronous tasks are started is the order that they complete.

所以你是对的。这实际上是此示例的一个错误,它没有正确的 load/display 逻辑。