Hello,
I am using a RecyclerView from the support library and i am currently displaying some view with a CheckBox inside. The checkbox is bound to the currently displayed object. When I click the checkbox, some background thread is activated to update the object in the database and then to produce a updated list of objects for the recycler view. The updated list will be given back to the main thread and adapter.notifyDataSetChanged() will be called. This happens in a matter of milliseconds and is working fine. But i've got one problem: The checkbox animation is stopped the moment notifyDataSetChanged is called. I've tried stuff like calling "setIsRecyclable(true)" on the holder and everything, but i have no idea how to stop the view from stopping my animations. :/
Do you guys have any idea?
Olli
Okay never mind, i've got it! Rubber duck debugging at it's best. While writing the post i got the idea, that the recyclerview can not know which item is which after the change. So I called "setHasStableId(true)" on my adapter and implemented "getItemId" which not only fixed my problem, but also added nice animations! Took me only 3 hours to get to this conclusion! Thank you, XDA! :)
I am using a RecyclerView from the support library and i am currently displaying some view with a CheckBox inside. The checkbox is bound to the currently displayed object. When I click the checkbox, some background thread is activated to update the object in the database and then to produce a updated list of objects for the recycler view. The updated list will be given back to the main thread and adapter.notifyDataSetChanged() will be called. This happens in a matter of milliseconds and is working fine. But i've got one problem: The checkbox animation is stopped the moment notifyDataSetChanged is called. I've tried stuff like calling "setIsRecyclable(true)" on the holder and everything, but i have no idea how to stop the view from stopping my animations. :/
Do you guys have any idea?
Olli
Okay never mind, i've got it! Rubber duck debugging at it's best. While writing the post i got the idea, that the recyclerview can not know which item is which after the change. So I called "setHasStableId(true)" on my adapter and implemented "getItemId" which not only fixed my problem, but also added nice animations! Took me only 3 hours to get to this conclusion! Thank you, XDA! :)
Aucun commentaire:
Enregistrer un commentaire