我有这样的代码:
protected void onPostExecute(final ArrayList<HashMap<String, String>> adapter) {
for (final HashMap<String, String> a : adapter) {
LatLng pos = new LatLng(Double.valueOf(a.get(TAG_latitude)), Double.valueOf(a.get(TAG_longitude)));
Log.e("pppppos", String.valueOf(pos.latitude));
Marker m = map.addMarker(new MarkerOptions().position(pos)
.title(a.get(TAG_NAME))
.snippet("Kiel is cool"));
map.setOnInfoWindowClickListener(
new OnInfoWindowClickListener(){
public void onInfoWindowClick(Marker marker){
Intent nextScreen = new Intent(SearchExchangerActivity.this, BankExchangersListActivity.class);
nextScreen.putExtra("exchanger_id", id);
startActivityForResult(nextScreen, 0);
}
});
}
但是我需要Tag_id
为每个标记设置对用户字段不可见,然后在向其他活动发送额外信息时使用此 ID,例如:
protected void onPostExecute(final ArrayList<HashMap<String, String>> adapter) {
for (final HashMap<String, String> a : adapter) {
LatLng pos = new LatLng(Double.valueOf(a.get(TAG_latitude)), Double.valueOf(a.get(TAG_longitude)));
Marker m = map.addMarker(new MarkerOptions().position(pos)
.title(a.get(TAG_NAME))
.snippet("Kiel is cool")
.Tag_id(TAG_ID));
map.setOnInfoWindowClickListener(
new OnInfoWindowClickListener(){
public void onInfoWindowClick(Marker marker){
Intent nextScreen = new Intent(SearchExchangerActivity.this, BankExchangersListActivity.class);
nextScreen.putExtra("exchanger_id", marker.get(TAG_ID));
startActivityForResult(nextScreen, 0);
}
});
}
是真的做吗?我怎样才能在我的听众中获得我正在点击的标记?
它也可以通过标题字段来完成......但是我在写作时遇到了错误marker.getTitle()
......
更新
for (final HashMap<String, String> a : adapter) {
LatLng pos = new LatLng(Double.valueOf(a.get(TAG_latitude)), Double.valueOf(a.get(TAG_longitude)));
Log.e("pppppos", String.valueOf(pos.latitude));
HashMap<Marker, String> m = new HashMap<Marker, String>();
m.put( map.addMarker(new MarkerOptions().position(pos)
.title(a.get(TAG_NAME))
.snippet("Kiel is cool")), "1");
}
map.setOnInfoWindowClickListener(
new OnInfoWindowClickListener(){
public void onInfoWindowClick(HashMap<Marker, String> marker){
Intent nextScreen = new Intent(SearchExchangerActivity.this, BankExchangersListActivity.class);
nextScreen.putExtra("exchanger_id", "1");
startActivityForResult(nextScreen, 0);
}
});