这是一个ListView,我可以显示城市和地点。我想显示从当前点到列出的位置的距离。
例如:
+++++++++++++++++++++++++
Name :Hotel Hilton
Category :hotel
distance:1km
+++++++++++++++++++++++++
如何计算和显示列表中的每个距离值?
ArrayList> contactList = new ArrayList>();
JSONArray jsonArray = new JSONArray(response);
if (jsonArray != null) {
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject object = (JSONObject) jsonArray.get(i);
HashMap map = new HashMap();
map.put(TAG_Name, object.getString("name"));
map.put(TAG_Category, object.getString("category"));
map.put(TAG_Lat, object.getString("lat"));
map.put(TAG_Lng, object.getString("lng"));
contactList.add(map);
}
}
ListAdapter adapter = new SimpleAdapter(this, contactList,
R.layout.menu_list_row, new String[] { TAG_Name,
TAG_Category }, new int[] { R.id.LR_Name,
R.id.LR_date });
list.setAdapter(adapter);
}
当前位置从GPS识别并存储为lat,lng。