我正在使用此代码。
for (j = 0; j < result.size()-1; j++) {
mMap.setInfoWindowAdapter(new InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker arg0) {
return null;
}
@Override
public View getInfoContents(Marker marker) {
View myContentView = getLayoutInflater().inflate(R.layout.custommarker, null);
TextView tvTitle = ((TextView) myContentView.findViewById(R.id.title));
tvTitle.setText(result.get(j).getName());
TextView tvSnippet = ((TextView) myContentView.findViewById(R.id.snippet));
tvSnippet.setText(result.get(j).getVicinity());
TextView tvPrice = ((TextView) myContentView.findViewById(R.id.price));
tvPrice.setText("Price: $100.00");
return myContentView;
}
});
mMap.addMarker(new MarkerOptions()
.title(result.get(j).getName())
.position(new LatLng(result.get(j).getLatitude(), result.get(j).getLongitude()))
.icon(BitmapDescriptorFactory.fromResource(icone))
.snippet(result.get(j).getVicinity()));
}
但它总是将最后一个结果的getName和getVicinity返回到每个标记。
我做错了什么?