sorting - How to sort arraylist hashmap in Android? -


i have fetch data website , take data value hashmap. create dynamic linear layout , display ol hashmap value in it. problem comes when want display hashmap value name , data type, how can that?

for (int = 0; < nodes.getlength(); i++)   {           element e = (element) nodes.item(i);         node node = nodes.item(i);         hashmap<string, string> map = new hashmap<string, string>();          lin = new linearlayout(this);         lin.setorientation(linearlayout.vertical);         lin.setbackgroundresource(r.drawable.my_border);          linearlayout linbsc = new linearlayout(this);         linbsc.setorientation(linearlayout.horizontal);         map.put("name",node.getattributes().getnameditem("name").getnodevalue());         textview txtbasicname = new textview(this);         txtbasicname.setlayoutparams(new layoutparams(layoutparams.wrap_content, layoutparams.fill_parent, 1f));                 //txtbasicname.setbackgroundcolor(color.white);         txtbasicname.settextcolor(color.white);         string strbasicname =map.put("name",node.getattributes().getnameditem("name").getnodevalue());         txtbasicname.settext(strbasicname);         linbsc.addview(txtbasicname);           lin.addview(linbsc);          linearlayout linthrd = new linearlayout(this);         linthrd.setorientation(linearlayout.horizontal);          map.put("venuetype",node.getattributes().getnameditem("venuetype").getnodevalue());         textview txtbasicvenuetype = new textview(this);         txtbasicvenuetype.settextcolor(color.white);         txtbasicvenuetype.setpadding(5, 0, 0, 0);         string strbasicvenuetype =map.put("venuetype",node.getattributes().getnameditem("venuetype").getnodevalue());         txtbasicvenuetype.settext(strbasicvenuetype+"-");         linthrd.addview(txtbasicvenuetype);            lin.addview(linthrd);          linearlayout linforth = new linearlayout(this);         linforth.setorientation(linearlayout.horizontal);         map.put("address",node.getattributes().getnameditem("address").getnodevalue());         textview txtbasicaddress = new textview(this);         txtbasicaddress.setpadding(5, 0, 0, 0);         txtbasicaddress.settextcolor(color.white);         string strbasicaddress =map.put("address",node.getattributes().getnameditem("address").getnodevalue());         txtbasicaddress.settext(strbasicaddress+",");         linforth.addview(txtbasicaddress);          map.put("city",node.getattributes().getnameditem("city").getnodevalue());         textview txtbasiccity = new textview(this);         txtbasiccity.settextcolor(color.white);         string strbasiccity =map.put("city",node.getattributes().getnameditem("city").getnodevalue());         txtbasiccity.settext(strbasiccity+",");         linforth.addview(txtbasiccity);           linearlayout linfifth = new linearlayout(this);         linfifth.setorientation(linearlayout.horizontal);          map.put("zip",node.getattributes().getnameditem("zip").getnodevalue());         textview txtbasiczip = new textview(this);         txtbasiczip.settextcolor(color.white);         txtbasiczip.setlayoutparams(new layoutparams(layoutparams.wrap_content, layoutparams.fill_parent, 1f));                  string strbasiczip =map.put("zip",node.getattributes().getnameditem("zip").getnodevalue());         txtbasiczip.settext(strbasiczip+".");         linfifth.addview(txtbasiczip);            lin.addview(linfifth);         linm.addview(lin);         datalist.add(map);          mylist.add(map);         }       system.out.println("data list = "+datalist);     system.out.println("data list = "+datalistfeture); 

you can sort hashmap using treemap as

treemap sortedmap1=new treemap<string, string>(hashmap object); 

the treemap automatically sorts keys so,we can sorted keyset() follows

sortedmap1.keyset(); 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -