我有一个带有自定义 ArrayAdapter
的 ListView
。此 ListView
中的每一行都有一个图标和一些文本。这些图标在后台下载、缓存,然后使用回调在各自的 ImageViews
中替换。每次 getView
() 运行时都会触发从缓存或下载中获取缩略图的逻辑。
现在,根据 Romain Guy 的说法:
"there is absolutely no guarantee on the order in which getView() will be called nor how many times."
我已经看到这种情况发生了,因为一行大小为 2 的 getView() 被调用了六次!
如何更改我的代码以避免重复的缩略图提取请求并处理 View 回收?
谢谢。
最佳答案
确切地说,这可能会发生,例如当你有
android:layout_height="wrap_content"
在您的 ListView
定义中。将其更改为 fill_parent/match_parent 将避免它。
关于android - 从适配器内部处理多个 getView 调用的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2872996/