galvan galvan - 2 months ago 8x
Android Question

Android - what is the meaning of StableIDs?

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?


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.

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.