android – 在Expandable ListView中有hasStableIds()?

前端之家收集整理的这篇文章主要介绍了android – 在Expandable ListView中有hasStableIds()?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在创建应用程序使用ExpandableListView,我引用了一些教程.TheStableIds()设置为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应更新其视图以反映更改.

如果为true,则如果ID相同,则ExpandableListView可以重用相同的View.

如果是false,它应该重新创建所有的视图,因为它不能知道什么变化.

我引用的ID是由getGroupId和getItemId返回的ID.

你也应该重写这个方法

一些问题:

> BaseAdapter: set hasStableIds() to false?
> Android – what is the meaning of StableIDs?

原文链接:https://www.f2er.com/android/311170.html

猜你在找的Android相关文章