1

As you can see down here I have a ListView populated by a JSON but I want to sort the list by date and to have the same items down the corresponding title.

In the image down the the row third and fourth have the same date but in different row.

I do not know what code should I show if the adapter or where I populate the list.

Figure 0

Enrique Diaz
  • 573
  • 4
  • 13
Jonathan Axel
  • 67
  • 2
  • 6
  • A question without any specific errors or minimal codes, seems to be off-topic! Be more specific in your question – frogatto Dec 31 '14 at 20:50

3 Answers3

1

I think U need to sort the populated data date wise in hashmap hashmap<date,list<other Object>>like this and then use expandable listview to show the populated data..

0

Is a basic. Have you ever try to Google it ?

Use a comparator.

    Collections.sort(yourList, new Comparator<YourObjectInYourList>() {   
public int compare(YourObjectInYourList o1, YourObjectInYourList o2) {
          if (o1.getDate() == null || o2.getDate() == null)
            return 0;
          return o1.getDate().compareTo(o2.getDate());   
} 
});
marshallino16
  • 2,645
  • 15
  • 29
0

In the spirit of having less computation processes into the Android client, I suggest you create a new method called findServicesByDate from the server, which should give you the right order based on dates.

However, if this is not possible, the only thing you have to do is order the array based on date, you should check this answer.

Community
  • 1
  • 1
Enrique Diaz
  • 573
  • 4
  • 13