guys I am developing android TV app so I used recyclerview horizontally and vertically and I used a method to refresh adapter of vertical recyclerview by using adapter.notifyDataSetChanged() but I am getting one problem. 1. It's focus is being gone and on press any D-pad key it is not working only right key is working 2. I used adapter.notifyItemRangeChanged(0, categoryDataList.size()) but I have still one problem that it's focus is going on first element of layout otherwise last of layout. So Please help me as soon as possible. Thanks in advance.
Of course item will lose focus. Because no view to get focus when you refresh RecyclerView by calling method notify*Changed.
There is an imperfect way to keep focus in RecyclerView when you call notifyDatasetChanged()
.
@Override public long getItemId(int position) { return position; }
adapter.setHasStableIds(true);
mRecyclerView.setItemAnimator(null);
about stable id:Android: How to make an adapter with stable ids?
about disable animator:How to implement ItemAnimator of RecyclerView to disable the animation of notifyItemChanged
about the reason of step3 in google code:
https://code.google.com/p/android/issues/detail?id=204277
Good luck!
Use
notifyItemRangeInserted(position,size);
if you are inserting items.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With