[英]How to add section divider in Recycler-view
Scenario : I am trying to add the section between items in the recycler view.场景:我正在尝试在回收站视图中添加项目之间的部分。 This divider is not with every element but it is based on the datasource.
这个分隔符不是每个元素都有,而是基于数据源。 My Datasource has a divider property for that cell it means it is a divider cell and a divider of
2dp*100dp
need to be shown in place of the normal cell data.我的数据源对该单元格有一个分隔符属性,这意味着它是一个分隔符单元格,需要显示一个
2dp*100dp
的分隔符来代替正常的单元格数据。
WorkDone : I tried to do that using two sibling inside the my recycler-view main cell-view which will be passed to the holder. WorkDone :我试图在我的回收站视图主单元格视图中使用两个兄弟来做到这一点,这将被传递给持有人。 In one sibling there is my main cell layout and in another one just the separator view and based on the datasource while binding I am changing the visibility of the each sibling.
在一个兄弟姐妹中有我的主单元格布局,在另一个兄弟姐妹中只有分隔符视图,并且在绑定时基于数据源我正在更改每个兄弟姐妹的可见性。 But I am facing that while scrolling back and forth multiple separator and coming at random placed and keep on increasing while scrolling.
但是我在来回滚动多个分隔符并随机放置并在滚动时继续增加时面临着这个问题。
Question :问题:
Sample UI : As there is divider between Instagram sizes ans Facebook sizes示例 UI :因为 Instagram 尺寸和 Facebook 尺寸之间存在分隔线
If you implement these scenario (having two types of holders) in a right way, i think it's the best way to achieve your goal.如果你以正确的方式实现这些场景(有两种类型的持有人),我认为这是实现你的目标的最佳方式。
After some more google targeted search able to find one solution:经过一些更多的谷歌有针对性的搜索能够找到一个解决方案:
Two view holder for different views.不同视图的两个视图持有者。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.