4

I am developing a comment section for my app. My goal is to create a way for users to reply to other comments and to be able to view and hide this comment list like on instagram:

instagram exemple

How can I create a replies list within an item in a RecyclerView? Also, how to show and hide the replies?

Thanks in advance!

Vitor Ferreira
  • 1,075
  • 1
  • 14
  • 28

2 Answers2

3

You can try with below design

  • All comments are located inside a RecyclerView.
  • Each item is a vertical LinearLayout(1) including:
    • First layer content a TextView (used for comment)
    • Second layer content another vertical linear layout(2), including:
      • a text view: View more replies
      • a second layer is another vertical linear layout(3) again enter image description here
  • The third linear layout will contain replies, and will be show/hide on text view "view more replies" clicks. Newly added replies will be add to linear layout 3 by LinearLayout.addView() method.

  • Refresh recycler view items at resonable time by calling recycler view adapter notifyDataSetChanged() or similar methods.

TaQuangTu
  • 2,155
  • 2
  • 16
  • 30
  • I've created a small example here https://github.com/yoobi/CommentApplication for anyone who needs it – Biscuit Sep 24 '21 at 07:05
0

you can make Expandable Recyclerview with the comment as the parent and the replies as the children you can check this library and use it or edit on it and use it https://github.com/thoughtbot/expandable-recycler-view

Reham Alatris
  • 425
  • 3
  • 14