Android的 - 什么是StableIDs的意义何在? [英] Android - what is the meaning of StableIDs?

查看:326
本文介绍了Android的 - 什么是StableIDs的意义何在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我采取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 Views 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 Views that kept their item IDs.

这篇关于Android的 - 什么是StableIDs的意义何在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆