How to sort RecyclerView item in android

前端 未结 7 1841
暖寄归人
暖寄归人 2021-01-01 11:29

I\'m working on a android chatting application. When I called my api it returns me the chat list sorted by a user_id. But what I need to do is serialized by

7条回答
  •  失恋的感觉
    2021-01-01 11:57

    Add this lines of code before passing to RecyclerView Adapter

    Collections.sort(yourLists, new Comparator() {
            @Override
            public int compare(YourList lhs, YourList rhs) {
                return lhs.getId().compareTo(rhs.getId());
            }
        });
    

提交回复
热议问题