Android sort ListView alphabetically

前端 未结 8 1160
后悔当初
后悔当初 2020-12-05 03:10

So I\'m trying to sort a simple ArrayAdapter for ListView. Here\'s what I\'ve tried:

ListView lv;
String[] months = {
        \"January\",
              


        
8条回答
  •  感情败类
    2020-12-05 03:45

    its simple if you already have another adapter you can just copy paste this code under declaration of adapter

    adapter.sort(new Comparator() {
            @Override
            public int compare(String arg1, String arg0) {
                return arg1.compareTo(arg0);
            }
        });
    

提交回复
热议问题