我采取ExpandableListView的ListAdapter,边工作边我看到,我需要在此改变函数布尔hasStableIds()。 任何人都可以请解释什么是稳定的id是什么意思?当我需要这个?
I'm implementing a ListAdapter of ExpandableListView, while working i see that i need to overide the function boolean hasStableIds(). Can anyone explain please what is the meaning of stable ids? when I need this?
稳定标识让的ListView
优化的情况下项目保持的同一 notifyDataSetChanged
调用。它指的ID来从 getItemId
返回的。
Stable IDs allow the ListView
to optimize for the case when items remain the same between notifyDataSetChanged
calls. The IDs it refers to are the ones returned from getItemId
.
没有它,的ListView
必须重新创建所有查看
取值,因为它不知道,如果该项目的ID是数据变化之间的相同(例如,如果ID与索引中的数据,它必须重新创建的所有内容)。有了它,就可以避免重建查看
s表示保留了他们的项目标识。
Without it, the ListView
has to recreate all View
s since it can't know if the item IDs are the same between data changes (e.g. if the ID is just the index in the data, it has to recreate everything). With it, it can refrain from recreating View
s that kept their item IDs.