有`ListView.invalidateViews()'和'Adapter.notifyDataSetChanged()“有什么区别?

编程入门 行业动态 更新时间:2024-10-22 20:40:50
本文介绍了有`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()“有什么区别?

本文发布于:2023-11-03 15:04:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1555424.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有什么区别   invalidateViews   ListView   notifyDataSetChanged   Adapter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!