Handle click item in Recycleview

后端 未结 5 1838
不知归路
不知归路 2021-01-07 08:52

I have a horizontal recycleview inside vertical recycleview.

and i add list cardview inside horizontal rec

5条回答
  •  轮回少年
    2021-01-07 09:12

    Looking at your code the VerticalRecyclerViewAdapter has a List and each Album in this list will require a HorizontalRecyclerViewAdapter to hold another List.

    In your VerticalRecylerViewAdapter create VerticalClickListener which will be implemented by your activity. Inside HorizontalRecyclerViewAdapter create HorizontalClickListener which will be implemented by your VerticalRecyclerViewAdapter for each Album. When creating the HorizontalRecyclerViewAdapter for each Album, pass in the vertical position as well. Then, when a cardview is clicked, the HorizontalClickListener can return the vertical position of the adapter and also the horizontal position of the cardview. The VerticalRecyclerViewAdapter will return the vertical and horizontal positions to your activity.

提交回复
热议问题