Answer the question
In order to leave comments, you need to log in
How to implement nested comments?
Please tell me how to implement nested comments on android?
Data:
id | comment | parent
1 - comment - 0
2 - comment - 0
3 - comment - 1
4 - comment - 0
5 - comment - 1
While thinking of such an option, bypass the resulting array and create a new array in which the data is ordered
1 - comment - 0
3 - comment - 1
5 - comment - 1
2 - comment - 0
4 - comment - 0
and then just display the data in the adapter. Is this the normal approach or is there a better way?
Answer the question
In order to leave comments, you need to log in
For starters, it's a great approach. Simplest. Will work.
Complicating it makes sense only when this option ceases to suit in some way.
For example, if there are over 100500 comments, then it will be problematic to transfer all this to the client. You will have to send a small (visible) part of the list to the client, and load the rest as you scroll (or click the "more" button). Therefore, sorting will have to be performed on the server (each time a new comment is added), saving the result of this sorting in the database. And the client request to the list of comments should be executed according to the ready sorted table.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question