hasStableIds() == true
means that item IDs do not change for the underlying data items, not that the data of that item never changes. E.g. the same contact has the same ID regardless where it appears in a list, but its name may change over time--user could edit it, add a nickname, etc. It's possible to imagine displaying data where each item does not have some stable ID (perhaps the data is not yours and you have no way to access a unique ID that is suitable to return from getItemId()
, e.g. not compatible with the long
return type).
In browsing the source code for AdapterView
and AbsListView
, it seems to me that this is mostly useful when you set a choice mode on a ListView/GridView, because then the view can do some more efficient management of checked item IDs and they're visual state, including across data set changes where those checked items may have moved to new positions (but they have the same ID).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…