In case of you need to see the full code, https://pastebin.com/Zxmq36Gn推荐答案在将列表传递给适配器之前(在API调用之后和适配器notifydatasetchanged之前)尝试以下操作:try this before passing your list to the adapter (after API call and before adapter notifydatasetchanged): Collections.sort(data, new Comparator<CustomData>() { @Override public int compare(CustomData lhs, CustomData rhs) { // -1 - less than, 1 - greater than, 0 - equal, all inversed for descending return lhs.getId() > rhs.getId() ? -1 : (lhs.customInt < rhs.customInt ) ? 1 : 0; } }); 这篇关于如何在Android中对RecyclerView项目进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-12 22:12