Android按属性对ArrayList进行排序

7 浏览
0 Comments

Android按属性对ArrayList进行排序

我想根据属性对一个ArrayList进行排序。这是我的代码...

public class FishDB{
    public static Object Fish;
    public ArrayList list = new ArrayList();
    public class Fish{
        String name;
        int length;
        String LatinName;
        //etc. 
        public Vis (String name) {
            this.name = name;
        }
    }
    public FishDB() {
        Fish fish;
        fish = new Fish("Shark");
        fish.length = 200;
        fish.LatinName = "Carcharodon Carcharias";
        fish = new Fish("Rainbow Trout");
        fish.length = 80;
        fish.LatinName = "Oncorhynchus Mykiss";
        //etc.
        }
    }
}

现在我想在另一个活动中按照属性(例如latinname)对这个ArrayList进行排序。但是我不知道如何做到。有人知道吗?

0