Reputation: 1
I've a custom ListView with 5 ArrayLists in the adaptor.
private ArrayList<String> name = new ArrayList<>();
private ArrayList<String> message = new ArrayList<>();
private ArrayList<Long> time = new ArrayList<>();
private ArrayList<String> imageId = new ArrayList<>();
private ArrayList<String> extras = new ArrayList<>();
ArrayList
time
contains remaining time in milliseconds. I want to display the list from lower to higher time left. If i just perform Collection.sort
on a single ArrayList, others will remain unchanged. How can i sort all the ArrayLists accordingly with time
.
I am passing all the ArrayLists to my custom adaptor at once.
Any suggestions?
Upvotes: 0
Views: 26
Reputation: 420
I think better to create a new class like this
class Class {
String name;
String message;
Long time;
String imageId;
String extras;
}
Then creating single ArrayList then you can sort it by any fields by creating Comparator you want
Upvotes: 1