Need an explanation why RecyclerView.Adapter.notifyItemChanged(int position, Object payload) and I bind payload parameter is List of objects

家住魔仙堡 提交于 2019-12-11 06:43:14

问题


RecyclerView.Adapter.notifyItemChanged(int position, Object payload), where payload is an arbitrary object that will be passed to RecyclerView.Adapter.onBindViewHolder(VH holder, int position, List payloads)

So why list of payloads passed in the bind method if I can't pass than 1 object on item changed?


回答1:


Well, there is a concept of Partial and Full binding in recycler view. This is what Android Developers site says about the onBindViewHolder method:

The payloads parameter is a merge list from notifyItemChanged(int, Object) or notifyItemRangeChanged(int, int, Object). If the payloads list is not empty, the ViewHolder is currently bound to old data and Adapter may run an efficient partial update using the payload info. If the payload is empty, Adapter must run a full bind. Adapter should not assume that the payload passed in notify methods will be received by onBindViewHolder(). For example when the view is not attached to the screen, the payload in notifyItemChange() will be simply dropped.

Reading this will help: onBindViewHolder - Android Developers



来源:https://stackoverflow.com/questions/41172427/need-an-explanation-why-recyclerview-adapter-notifyitemchangedint-position-obj

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!