gpt4 book ai didi

android - Expandable ListView 中的 hasStableIds ()?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:02:04 28 4
gpt4 key购买 nike

我正在使用 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com