gpt4 book ai didi

java - 如何按前缀整数值对 ArrayList 进行排序

转载 作者:行者123 更新时间:2023-11-30 10:01:56 25 4
gpt4 key购买 nike

<分区>

如何搜索前面有数字值的sort arraylist,计划是我想从最大到最小的数字对listview进行排序

private void setupData(){
ArrayList<String> hasil = new ArrayList<>();
Set<String> keySet = chains.keySet();
for(String key : keySet){
float ms = Float.parseFloat(chains.get(key).get(0));
float ma = 0;
for(String str : chains.get(key)){
if(str.contains(","))
ma += Float.parseFloat(str.split(",")[1]);
}

float pa = ma * 100;
String namaGangguan = SQLiteHelper.getInstance(this).getGangguan(key).getNama();
hasil.add((int)pa + " % " + namaGangguan); // this is i want sorting
}

Collection.sort(hasil); //this is my code

ArrayAdapter<String> diagnoseAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, hasil);
listView.setAdapter(diagnoseAdapter);
}

如何搜索前面有数字值的sort arraylist,计划是我想从最大到最小的数字对listview进行排序

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com