有`ListView.invalidateViews()'和'Adapter.notifyDataSetChanged()“有什么区别? [英] Is there any difference between `ListView.invalidateViews()` and 'Adapter.notifyDataSetChanged()'?

查看:603
本文介绍了有`ListView.invalidateViews()'和'Adapter.notifyDataSetChanged()“有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有间 ListView.invalidateViews任何区别() Adapter.notifyDataSetChanged()

推荐答案

嗯,是的,有。

ListView.invalidateViews()是用来告诉ListView中其所有子项的意见(重绘他们)无效。 注意,这里并不需要同等数量的意见比项目。的这是因为一个ListView循环利用项目的意见和移动周围的屏幕一个聪明的办法,而你滚动。

ListView.invalidateViews() is used to tell the ListView to invalidate all its child item views (redraw them). Note that there not need to be an equal number of views than items. That's because a ListView recycles its item views and moves them around the screen in a smart way while you scroll.

Adapter.notifyDataSetChanged(),另一方面,是要告诉大家,什么是适合的内容已更改适配器的观察者。通报改变了数据集将导致列表视图再次调用你的适配器的方法来调整滚动条,重新生成项目的意见,等等...

Adapter.notifyDataSetChanged() on the other hand, is to tell the observer of the adapter that the contents of what is being adapted have changed. Notifying the dataset changed will cause the listview to invoke your adapters methods again to adjust scrollbars, regenerate item views, etc...

在大多数情况下,你可能需要使用 notifyDataSetChanged ,而不是 invalidateViews 的,但它肯定取决于你试图完成。

Most of the time you would want to use notifyDataSetChanged instead of invalidateViews, but it certainly depends on what you are trying to accomplish.

这篇关于有`ListView.invalidateViews()'和'Adapter.notifyDataSetChanged()“有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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