Dynamically adding Views in a RecyclerView only to current item

前端 未结 8 2047
一向
一向 2020-12-20 12:08

I\'m dynamically adding Views to my items in a RecyclerView. These added Views should only be related to the item which they\'re added to, but I\'m having a pro

8条回答
  •  渐次进展
    2020-12-20 13:00

    In your adapter class of your recyclerView, in the onBindViewHolder method, create another adapter and do the same methods for your new adapter.

    The hierarchy will be,

    mainRecyclerView -> item1(->childRecyclerView1) , item2(->childRecyclerView2), item3(->childRecyclerView3)

    This way you can achieve what you want without wrong values to be viewed on wrong items.

提交回复
热议问题