Android Sorting ListView -


i have several arraylists going listview adapter. i'm trying sort 1 of arraylists...

    names = new arraylist<string>();     locations = new arraylist<string>();     timedates = new arraylist<string>();      //arraylists populated here      adapter = new homeadapter(getactivity(), names, locations, timedates);     setlistadapter(adapter); 

how go sorting entire listview timedates example?

appreciate help. thanks!

you have use datamodel 1 arrylist. details given bellow:

arraylist= new arraylist<datamodel>();  //arraylists populated here  adapter = new homeadapter(getactivity(), arraylist); setlistadapter(adapter); 

datamodel class this:

public class datamodel {      public string names;     public string locations;     public string timedates;  } 

finally sorting:

collections.sort(arraylist, new sortlist());  public class sortlist implements comparator<datamodel> {     public int compare(datamodel arg0, datamodel arg1) {         int flag = arg0.timedates.compareto(arg1.timedates);         return flag;     } } 

edit 1:

to add data list:

datamodel datamodel = new datamodel(); datamodel.names = "ashiq"; datamodel.locations = "khulna, bangladesh"; datamodel.timedates = system.currenttimemillis();   arraylist.add(datamodel); 

you don't have use arraylist individually each item. wrap strings datamodel , add arraylist adding each set of data.

let me know if not seem clear.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -