[英]How to make structural changes in recycler view at runtime. For adding the click to like functionality
I want to make Facebook or Instagram like RecyclerView
. 我想使Facebook或Instagram像
RecyclerView
一样。 The problem comes when the user taps the like button, no visual changes occur. 当用户点击“赞”按钮时,问题就不会出现。
notifyItemChanged()
changes the whole data set after that position. notifyItemChanged()
更改该位置之后的整个数据集。
You shouldn't notify adapter that all data changed when you actually changed one item. 当您实际更改一项时,您不应该通知适配器所有数据都已更改。 Use
void notifyItemChanged (int position, Object payload)
on specific item position and then you can retrieve it in void onBindViewHolder (VH holder, int position, List<Object> payloads)
在特定项目位置上使用
void notifyItemChanged (int position, Object payload)
,然后可以在void onBindViewHolder (VH holder, int position, List<Object> payloads)
检索它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.