我正在使用listview来显示数据,在listview中我在每个上下文中使用图像.
从包装类调用以下方法
public View getView(int position, View convertView,
ViewGroup parent) { // implementation }
Run Code Online (Sandbox Code Playgroud)
我正在关注本教程 http://developer.android.com/guide/samples/ApiDemos/src/com/example/android/apis/view/List4.html
class DownloadImage extends AsyncTask<Void, Void, Drawable>{
@Override
protected Drawable doInBackground(Void... params) {
return Util.getImageFromURL(imageURL);
}
@Override
protected void onPostExecute( Drawable d ) {
getImageIcon().setImageDrawable(d);
}
}
new DownloadImage().execute();
Run Code Online (Sandbox Code Playgroud)
上面的代码为每个listItem执行延迟图像上传.
问题是加载后第一个图像图像相互重叠....任何想法为什么会发生这种情况?
ListView行得到回收.您可能正在更新已回收的行,因此相关图像不再有效.
在我的cwac-thumbnail项目中,我将URL放在标签中ImageView,然后ImageView在我更新图像时确认仍有该标签.这样,如果ImageView现在需要不同的图像,我不会改变它以显示错误的图像.
| 归档时间: |
|
| 查看次数: |
1239 次 |
| 最近记录: |