android - How to get separate key and value of hashmap without iteration -
here key difference of latitude , longitude , value list of string values. want separate key , value of hashmap.
possible that??? please suggest me.
mainactivity.java
public void getexpandablelistdata() { cursor cursor = databasehelper.getloadmoredata(count); cursor.movetofirst(); string businessname; string latitude; string longitude; string categorydescription; double difference; log.i(tag, "cursor.getcount() :" + cursor.getcount()); { categorydescription = cursor.getstring(cursor .getcolumnindex("categorydesc")); log.i("categorydescription", "" + categorydescription); int categoryid = cursor.getint(cursor.getcolumnindex("categoryid")); log.i("category id", "" + cursor.getint(cursor.getcolumnindex("categoryid"))); listdataheader.add(categorydescription); log.w("list data header", "" + listdataheader); currentlocation = new location(""); currentlocation.setlatitude(18.5522); currentlocation.setlongitude(73.8956); 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); location savedlocation = new location("databaselocation"); savedlocation.setlatitude(double.parsedouble(latitude)); savedlocation.setlongitude(double.parsedouble(longitude)); difference = currentlocation.distanceto(savedlocation) * (0.001); hashmaplocationdifference.put(difference, childlist); hashmaplocationdifference = sortbykeys(hashmaplocationdifference); log.i("sortedhashmap:", "" + hashmaplocationdifference); set<double> keyset = new linkedhashset<double>(); keyset = hashmaplocationdifference.keyset(); entry = hashmaplocationdifference.entryset().iterator().next(); list = new arraylist<childinfo>(); list = entry.getvalue(); listdatachild.put(categorydescription, list); } while (cursorchild.movetonext()); } while (cursor.movetonext()); cursor.close(); } i don't want use iteration or loop keyset(). how use without iteration?
you can use keyset , entryset retrieve keys , entries respectively
Comments
Post a Comment