I´m doing an assignment and it´s required to support API16.
My view is a custom ArrayListAdapter with takes an
ArrayList<someclass>
The problem is that I want to make it possible to sort the data the user has put in the list.
items.sort(new Comparator<someclass>() {
@Override
public int compare(someclass item1, someclass item2) {
return item1.Name.compareTo(item2.Name);
}
});
But when I try Android Studio tells that I need API 24.
how do I sort the list in API 16?
You can use Collections.sort
Collections.sort(items, new Comparator<someclass>() {
@Override
public int compare(someclass item1, someclass item2) {
return item1.Name.compareTo(item2.Name);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With