i want sorted value based on key used treemap given sorted key want sorted key value according key. here key double , value array-list.
mainactivity.java
public void getexpandablelistdata() { cursor cursor = databasehelper.getloadmoredata(count); cursor.movetofirst(); string businessname; string latitude; string longitude; string categorydescription; double difference; { treemap<double, list<childinfo>> treemaplocationdifference; treemaplocationdifference = new treemap<double, list<childinfo>>(); categorydescription = cursor.getstring(cursor .getcolumnindex("categorydesc")); int categoryid = cursor.getint(cursor.getcolumnindex("categoryid")); listdataheader.add(categorydescription); list<childinfo> childlist = new arraylist<childinfo>(); cursor cursorchild = databasehelper.getchilddata(categoryid); map.entry<double, list<childinfo>> entry; list<childinfo> list = null; cursorchild.movetofirst(); { businessname = cursorchild.getstring(cursorchild .getcolumnindex("businessname")); phonenumber = cursorchild.getstring(cursorchild .getcolumnindex("phone")); categorydescription = cursorchild.getstring(cursorchild .getcolumnindex("categorydesc")); latitude = cursorchild.getstring(cursorchild .getcolumnindex("latitude")); longitude = cursorchild.getstring(cursorchild .getcolumnindex("longitude")); childinfo childinfo = new childinfo(businessname, phonenumber, categorydescription, latitude, longitude); childlist.add(childinfo); currentlocation = new location(""); currentlocation.setlatitude(18.5522); currentlocation.setlongitude(73.8956); location savedlocation = new location("databaselocation"); savedlocation.setlatitude(double.parsedouble(latitude)); savedlocation.setlongitude(double.parsedouble(longitude)); difference = currentlocation.distanceto(savedlocation) * (0.001); treemaplocationdifference.put(difference, childlist); entry = treemaplocationdifference.entryset().iterator().next(); list = new arraylist<childinfo>(); list = entry.getvalue(); listdatachild.put(categorydescription, list); } while (cursorchild.movetonext()); } while (cursor.movetonext()); cursor.close(); } here used tree-map , want tree-map sorted key corresponding value assign value value of hash-map should sorted.
Comments
Post a Comment