如何清除 ListView 的 RecycleBin 中的视图? [英] How to clear the views which are held in the ListView's RecycleBin?

查看:19
本文介绍了如何清除 ListView 的 RecycleBin 中的视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Android 的 ListView 小部件中,ListView 将保存从内部类 getView 方法获得的视图>回收站.

In Android's ListView widget, the ListView will hold the views which is got from getView method of an Adapter in a inner class RecycleBin.

如何清除 RecycleBin 中的视图并强制 ListView 重新创建所有子视图.

How can I clear the views in the RecycleBin and force the ListView to recreate all the child views.

推荐答案

如果我没记错的话,在 ListView 小部件上调用 invalidate 将清空 Views.由于潜在的性能问题,我建议不要清空 ListView 的视图缓存.

If I remember correctly a call to invalidate on a ListView widget will empty the cache of Views which are currently stored. I would advise against emptying the cache of views of a ListView because of the potential performance issues.

如果您不打算使用 convertView 项,那么您最终将不得不每次都构建行视图(导致每次用户滚动时构建大量对象)+ 被来自 RecycleBin 的回收视图占用的额外内存,无论如何都不会被使用.

If you're not going to use the convertView item then you'll end up with having to build the row view each time(resulting in a lot of objects constructed each time the user scrolls) + the extra memory occupied by the recycled views from the RecycleBin which will never be used anyway.

这篇关于如何清除 ListView 的 RecycleBin 中的视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆