When I click a button to sort the listview, it works but only if I start scrolling the listview does it show the sort order.
This is what I have in my data model class:
public static Comparator<Emplyoyee> sortNameAtoZ = new Comparator<Emplyoyee>() {
@Override
public int compare(Emplyoyee lhs, Emplyoyee rhs) {
String emp1 = lhs.getName();
String emp2 = rhs.getName();
return emp1.compareTo(emp2);
//descending order
//return StudentName2.compareTo(StudentName1);
}};
When the user clicks the button, I call this:
Collections.sort(rowdata, EmployeeRowData.sortNameZtoA);
adapter.notifyDataSetChanged();
After doing the research and comparing different sources, the setup is the same as it is here but it is not sorting the listview instantly upon clicking the button. I'm populating the listview with data from a remote database using Volley.