donkingliang / GroupedRecyclerViewAdapter

GroupedRecyclerViewAdapter可以很方便的实现RecyclerView的分组显示,并且每个组都可以包含组头、组尾和子项;可以方便实现多种Type类型的列表,可以实现如QQ联系人的列表一样的列表展开收起功能,还可以实现头部悬浮吸顶功能等。
Apache License 2.0
1.65k stars 216 forks source link

只有组头时,子布局实现多布局时上下滑动复用数据出现紊乱 #62

Closed lutao2599 closed 3 years ago

lutao2599 commented 3 years ago

请问大神该怎么解决?

donkingliang commented 3 years ago

子布局数据出现紊乱一般是因为 1、getChildViewType返回的type没有保证唯一,每种item需要保证一个唯一的type。 2、onBindChildViewHolder中没有判断type来绑定数据。

你查一下你的代码,看是那里写错了。

lutao2599 commented 3 years ago

后台返回的item中的viewType重复可以吗?

------------------ 原始邮件 ------------------ 发件人: "donkingliang/GroupedRecyclerViewAdapter" <notifications@github.com>; 发送时间: 2020年12月1日(星期二) 下午4:38 收件人: "donkingliang/GroupedRecyclerViewAdapter"<GroupedRecyclerViewAdapter@noreply.github.com>; 抄送: "追梦赤子"<1336440850@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [donkingliang/GroupedRecyclerViewAdapter] 只有组头时,子布局实现多布局时上下滑动复用数据出现紊乱 (#62)

子布局数据出现紊乱一般是因为 1、getChildViewType返回的type没有保证唯一,每种item需要保证一个唯一的type。 2、onBindChildViewHolder中没有判断type来绑定数据。

你查一下你的代码,看是那里写错了。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

donkingliang commented 3 years ago

不可以,viewType是getChildViewType返回,用于识别item布局类型的,必须是唯一的。而且头、尾、子项的viewType也不能重复。

lutao2599 commented 3 years ago

不过我做了处理,返回的是viewType相同的我返回了同一个类型,这样也不行吗?

------------------ 原始邮件 ------------------ 发件人: "donkingliang/GroupedRecyclerViewAdapter" <notifications@github.com>; 发送时间: 2020年12月1日(星期二) 下午5:04 收件人: "donkingliang/GroupedRecyclerViewAdapter"<GroupedRecyclerViewAdapter@noreply.github.com>; 抄送: "追梦赤子"<1336440850@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [donkingliang/GroupedRecyclerViewAdapter] 只有组头时,子布局实现多布局时上下滑动复用数据出现紊乱 (#62)

不可以,viewType是getChildViewType返回,用于识别item布局类型的,必须是唯一的。而且头、尾、子项的viewType也不能重复。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

donkingliang commented 3 years ago

只要保证一种type对应一种布局和数据就可以。