我正在使用 ExpandableListView 创建应用程序,我引用了一些教程。hasStableIds () 设置为 false?使 hasStableIds() 为 false 的确切需要是什么?
最佳答案
hasStableIds()
的文档
Indicates whether the child and group IDs are stable across changes to the underlying data.
Returns whether or not the same ID always refers to the same object
它在您更改适配器的数据时使用,每次更改数据时 ExpandableListView
都应该更新它的 View 以反射(reflect)更改。
如果为 true,则 ExpandableListView
可以在 ID 相同的情况下重用相同的 View
。
如果为 false,它应该重新创建所有 View ,因为它不知道发生了什么变化。
我引用的ID是getGroupId
返回的ID和 getItemId
。
你也应该覆盖这个方法!
一些问题:
关于android - Expandable ListView 中的 hasStableIds ()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24385416/