0

我正在使用 google maps api v2 开发一个应用程序,并且我有一些标记。使用 onInfoWindowClick,我删除了标记,但我想显示一个带有“删除”和“取消”按钮的确认弹出窗口,以便用户可以确认删除。那可能吗?这是我的代码,我的问题是我无法访问“onClick”中的“标记”:

public void onInfoWindowClick(Marker marker) {
LayoutInflater li = LayoutInflater.from(context);
final View v = li.inflate(R.layout.deletelayout, null);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setView(v);
builder.setCancelable(true);
builder.setPositiveButton("Delete", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which){
       //I cannot get access to the marker in here
    }});
builder.setNegativeButton("Cancel", null);
AlertDialog alert = builder.create();
alert.show();

//marker.remove();

}

4

1 回答 1

4

改变public void onInfoWindowClick(Marker marker) {

public void onInfoWindowClick(final Marker marker) {

您现在应该能够访问您的标记变量onClick

于 2013-03-28T17:50:33.687 回答