Using one linear recyclerview, when I update the l...
# android
a
Using one linear recyclerview, when I update the list data lets say from meters to centimeters and calling notifyDataSetChange() on adapter afterwards, it changes/shuffles the position of items(edittexts inputs for numbers) in recyclerview. How can I prevent the list from shuffling and retaining the same position for converted items? Is Diffutill recommended for this to work?
stackoverflow 2
u
Are you using hashmap? If yes then use linkedhashmap it remains the order as the data inserted
👍 2
a
No, I am using simple array list. I am just recalculating the results in adapter class but the some edittext values get swaped. I need to make sure the consistent UI to the user.
u
If you are storing edittext values from list and setting it to edittext in onbindviewholder so it will work If you are using edittext for storing values so when you scroll it definitely swap values
d
try setting the itemIds on the list 🙂
blob hug 1
a
Use notifyItemChanged(position:Int)