So I\'m trying to sort a simple ArrayAdapter
for ListView. Here\'s what I\'ve tried:
ListView lv;
String[] months = {
\"January\",
its simple if you already have another adapter you can just copy paste this code under declaration of adapter
adapter.sort(new Comparator<String>() {
@Override
public int compare(String arg1, String arg0) {
return arg1.compareTo(arg0);
}
});
Rather than add data directly to your adapter, you can add them in Collection. Than sort the collection by using compactor. and finally...
adapter.addAll(collectionData);