• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to sort a listview with comparator ?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, this is my first post on this board. I am a java beginner, and i have a problem that cant figure how to resolve it.
Im getting the info from a xml feed, and put the info in a listview. Everthing works fine, but the only problem is that i want to sort by Time the listview.
I know that i need to do it with Collections.sort , but cant figure how to do it.
Hope someone could help me on this one.


Here is the code....

 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
filipe oliveira,
Welcome to Java Ranch...

Your post is not clearly stated your problem. Yes, you can use Comparator to sort a list...

And please use the UseCodeTags whenever you submit any code.
 
filipe oliveira
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry about the CodeTags. I have edited the post with them now.

I´m going to explain my problem. I receive the data from a xml feed. Then, i populate a listview with that data. Works fine.
The problem, is that the items of that xml are not sorted by item datetime. So, i would like to sort the listview by datetime of each item from the xml feed.

I´ve read and google it, try some examples that i found, and know that the sort have to be made with the collections.sort and a comparator (of the datetime of the xml items ), but i just get stuck.

Maybe someone can help me on this.



reply
    Bookmark Topic Watch Topic
  • New Topic