map.setOnInfoWindowClickListener(new OnInfoWindowClickListener()
{
public void onInfoWindowClick(Marker marker)
{
Intent intent = new Intent(NearbyAttractions.this,Activity2.class);
intent.putExtra("Clubname", ParseXMLMethods.getValue(e, KEY_TITLE));
intent.putExtra("Username", Username);
intent.putExtra("ID2", UserID);
startActivity(intent);
}
});
总是得到最后一个位置名称,并且我在哪里声明e作为最终变量而没有声明最终我得到了一个错误。我的要求是如果我点击特定标记开始新的活动我在哪里传递位置名称。
答案 0 :(得分:0)
InfoWindow不是一个实时视图,所以这就是我所做的:
public class CustomInfoWindowAdpater implements GoogleMap.InfoWindowAdapter,Picasso.Listener {
@Override
public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
}
private final View view;
public CustomInfoWindowAdpater() {
view = getLayoutInflater()
.inflate(R.layout.custominfowindow, null);
}
public View getInfoWindow(final Marker marker) {
MainApplication.currentlyClickedMarker = marker;
final LinearLayout linearLayout = (LinearLayout)view.findViewById(R.id.ll_custominfowindow);
linearLayout.setTag(marker.getId());
GoogleMapFragment.this.marker = marker;
String url = null;
if (marker.getId() != null && markers != null && markers.size() > 0) {
if ( markers.get(marker.getId()) != null &&
markers.get(marker.getId()) != null) {
url = markers.get(marker.getId());
}
}
final ImageView image = ((ImageView) view.findViewById(R.id.badge));
//Get the Image from web using Picasso and update the info contents
if (url != null && !url.equalsIgnoreCase("null")
&& !url.equalsIgnoreCase("")) {
Picasso.with(GoogleMapFragment.this).load(Uri.parse(url)).resize(50,50)
.into(image, new Callback() {
@Override
public void onSuccess() {
getInfoContents(marker);
}
@Override
public void onError() {
}
});
}
else{
image.setImageResource(R.drawable.ic_launcher);
}
final String title = marker.getTitle();
final TextView titleUi = ((TextView) view.findViewById(R.id.title));
if (title != null) {
titleUi.setText(title);
} else {
titleUi.setText("");
}
final String snippet = marker.getSnippet();
final TextView snippetUi = ((TextView) view
.findViewById(R.id.snippet));
if (snippet != null) {
snippetUi.setText("");
} else {
snippetUi.setText("");
}
return view;
}
...
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
googleMap.setInfoWindowAdapter(new CustomInfoWindowAdpater());
}
...
@Override
public void onInfoWindowClick(Marker marker) {
// open the application
Intent intent = new Intent(GoogleMapFragment.this,SplashScreenAppPro.class);
// SplashScreen
intent.putExtra("id",marker.getSnippet());
intent.putExtra("nom_profil", marker.getTitle());
startActivity(intent);
}
*您的活动/片段必须实施GoogleMap.OnInfoWindowClickListener