【问题标题】:Android - Show confirm dialog before deleting markerAndroid - 在删除标记之前显示确认对话框
【发布时间】:2013-03-28 17:45:57
【问题描述】:

我正在使用 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();

}

【问题讨论】:

    标签: android google-maps marker


    【解决方案1】:

    更改public void onInfoWindowClick(Marker marker) {

    public void onInfoWindowClick(final Marker marker) {

    您现在应该可以访问 onClick 中的标记变量

    【讨论】:

      猜你喜欢
      • 2020-12-12
      • 1970-01-01
      • 2017-07-21
      • 2016-02-06
      • 2017-08-22
      • 2021-08-02
      • 2018-10-10
      • 1970-01-01
      • 2020-12-02
      相关资源
      最近更新 更多