如何创建带有回复的评论部分? - 安卓 [英] How to create a comment section with reply? - Android
问题描述
我正在为我的应用程序开发一个评论部分.我的目标是为用户提供一种回复其他评论的方式,并能够像在instagram上一样查看和隐藏此评论列表:
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:
如何在RecyclerView中的项目内创建答复列表?另外,如何显示和隐藏回复?
How can I create a replies list within an item in a RecyclerView? Also, how to show and hide the replies?
提前谢谢!
推荐答案
您可以尝试以下设计
- 所有评论都位于RecyclerView内部.
- 每个项目都是垂直LinearLayout (1),包括:
- 第一层包含一个TextView(用于评论)
- 第二层包含另一种垂直线性布局(2),包括:
- 文本视图:查看更多回复
- 第二层是另一种垂直线性布局(3)
- 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
第三个线性布局将包含答复,并且将在文本视图查看更多答复"单击上显示/隐藏.新添加的回复将通过
LinearLayout.addView()
方法添加到线性布局3.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.通过调用回收器视图适配器
notifyDataSetChanged()
或类似方法,在合理的时间刷新回收器视图项目.Refresh recycler view items at resonable time by calling recycler view adapter
notifyDataSetChanged()
or similar methods.这篇关于如何创建带有回复的评论部分? - 安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!