I have a customlist view with an ImageView and a textview. I am retrieving that list view by this method:
private List<Currency> getModel() {
List<Currency> list = new ArrayList<Currency>();
for (int i = 0; i < countryCode.length; i++) {
list.add(get(countryCode[i], flag[i]));
}
return list;
}
this method returns a list of an image and a textview in a particular list item, and I am setting this in a adapter to show it in a listview. But how can I sort this list by alphabetically comparing with the text of that text view in the list? I have tried this
Collections.sort(list, new Comparator<String>() {
@Override
public int compare(String s1, String s2) {
return s1.compareToIgnoreCase(s2);
}
});
but this method only works for string types list, but my list is not in string type? What to do?
Try to compare in this way