0
嗨,我適配器如下排序適配器列表
public class ApplicationInfo implements Comparable<ApplicationInfo> {
public String name;
public String packageName;
public String status;
public Drawable icon;
@Override
public int compareTo(ApplicationInfo another) {
MainActivity cls = new MainActivity();
cls.sort(ApplicationContext.getAppContext());
if (cls.sort(ApplicationContext.getAppContext()) == 1){
return name.compareToIgnoreCase(another.name); // ascending
}else if (cls.sort(ApplicationContext.getAppContext()) == 2){
return another.name.compareToIgnoreCase(name); // descending
} else if (cls.sort(ApplicationContext.getAppContext()) == 3){
if(status.equals(another.status)){
return name.compareToIgnoreCase(another.name);
}else {
return status.equals("Not Installed") ? 1 : -1; // installed up along with ascending names
}
} else if (cls.sort(ApplicationContext.getAppContext()) == 4){
if(status.equals(another.status)){
return name.compareToIgnoreCase(another.name);
}else {
return status.equals("Installed") ? 1 : -1; // not installed up along with ascending names
}
} else
return this.name.compareToIgnoreCase(another.name); // ascending
}
}
現在
我想要做的是,我想排序基於包的名字也加上,包括姓名和安裝狀態
例如
分揀1和2使名稱升序和降序
和排序3和4使第一檢查名稱,然後檢查狀態
現在我要的是整理5和6檢查名稱,然後檢查安裝(如圖3和4這是工作的罰款相同)的狀態,並檢查包名
因此,如果應用程序是
ABC ABC 安裝
BCD AAA 安裝
應該排序列表類似下面
應用與名稱和包名稱,並在頂部
爲什麼不使用比較器接口 –
你能舉個例子嗎?我完全困惑如何做到這一點我已經添加了兩個檢查首先檢查狀態,然後名稱和對齊現在變得困惑,以實現所有3合一 –