微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.jb51.cc/android/311170.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐