2013-03-28 30 views
0

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

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

变化public void onInfoWindowClick(Marker marker) {

public void onInfoWindowClick(final Marker marker) {

你现在应该能够访问您的onClick

+0

它的工作原理,非常感谢你! – moyo