Recyclerview Adapter hasStableIds
from the CommonsWare Community archivesAt May 4, 2018, 1:07pm, rd7773 asked:
I am using a recyclerview inside a HorizontalGridView from leanback library and when i call notifydatasetChanged on the inner recyclerview (child of HorizontalGridview) while pressing DPAD-UP i.e. scrolling the list, the focus just jumps over here and there (jumps to adjacent child of HorizontalGridview may be because android just finds the next focusable view).
It got fixed by setting hasStableIds to true and returning position from getItemId() but i am really not sure what it did internally and how stableIds works.
I have looked around over the internet but couldn’t find any good explanation of what these stableIds do in recyclerviews.
It would really help if you could explain what these stableIds do and how to implement getItemId() in recyclerview adapter.
At May 4, 2018, 1:33pm, mmurphy replied:
I cannot really tell you anything other than what is already in the documentation for hasStableIds()
and getItemId()
. In particular, I cannot tell you under what conditions RecyclerView
will use those methods. I have never used either of those methods.
Sorry!