ListView の次のコードがあります。
private class CollegeItem {
private double gpa;
private int act;
private int sat;
private String name;
private String location;
private double score;
private boolean match;
private double scoreDistance;
private boolean uaero, uagri, ubio, uchem, ucivil, ucomp, uelec, uphys, uenvi, uindus, umate, umech;
public CollegeItem(double gpa, int act, int sat, String name, String location, boolean uaero, boolean uagri, boolean ubio, boolean uchem,
boolean ucivil, boolean ucomp, boolean uelec, boolean uphys, boolean uenvi, boolean uindus, boolean umate, boolean umech){
this.gpa = gpa;
this.act = act;
this.sat = sat;
this.name = name;
this.location = location;
this.uaero = uaero;
this.uagri = uagri;
this.ubio = ubio;
this.uchem = uchem;
this.ucivil = ucivil;
this.ucomp = ucomp;
this.uelec = uelec;
this.uphys = uphys;
this.uenvi = uenvi;
this.uindus = uindus;
this.umate = umate;
this.umech = umech;
if(act/36.0>sat/2400.0){
this.score = 0.6*gpa*25.0+0.4*(act/36.0)*100.0;
}else{
this.score = 0.6*gpa*25.0+0.4*(sat/2400.0)*100.0;
}
scoreDistance = Math.abs(this.score-MainActivity.scoreDouble)/MainActivity.scoreDouble;
if(uagri&&ListOfMajors.agricultural||uchem&&ListOfMajors.chem||uaero&&ListOfMajors.aerospace||ubio&&ListOfMajors.biomed||ucivil&&ListOfMajors.civil
||ucomp&&ListOfMajors.computer||uelec&&ListOfMajors.electrical||uphys&&ListOfMajors.physics||uenvi&&ListOfMajors.environment||uindus&&ListOfMajors.industrial
||umate&&ListOfMajors.materials||umech&&ListOfMajors.mechanical){
scoreDistance--;
}else{
scoreDistance = Math.abs(this.score-MainActivity.scoreDouble)/MainActivity.scoreDouble;
}
}
ArrayList<CollegeItem> collegeLists=new ArrayList<CollegeItem>();
ArrayList<String> nameList = new ArrayList<String>();
Comparator<CollegeItem> compare = new Comparator<CollegeItem>(){
public int compare(CollegeItem a, CollegeItem b){
return Double.compare(a.getScoreDistance(), b.getScoreDistance());
}
};
Collections.sort(collegeLists, compare);
for(CollegeItem collegeList : collegeLists){
nameList.add(collegeList.getName());
}
setListAdapter(new ArrayAdapter<String>(CollegeList.this, android.R.layout.simple_list_item_1, nameList));
現時点では、ListView の順序は、フィールド変数 scoreDistance の昇順です。このようにコンパレーターを介してソートされます。List の実際の内容は、フィールド変数名です。ここで、フィールド変数の場所を各名前のサブアイテムとして追加したいと思います。同じように並べ替える必要があります。サブアイテムの追加に関する複数の質問を見てきましたが、これを行う方法がまだわかりません. 私は何をすべきか?