降序排序
Collections.sort(list, new Comparator<House2>() { @Override public int compare(House2 house2, House2 t1) { int i = house2.getPrice() - t1.getPrice(); if(i>0){ return -1; } return 0; } }); //记得刷新数据 adapter.notifyDataSetChanged();
升序排序
Collections.sort(list, new Comparator<House2>() { @Override public int compare(House2 house2, House2 t1) { int i = house2.getPrice() - t1.getPrice(); if(i<0){ return -1; } return 0; } }); adapter.notifyDataSetChanged();