【问题标题】:Is it possible to add an OnClick Intent to one of these markers? [closed]是否可以将 OnClick Intent 添加到这些标记之一? [关闭]
【发布时间】:2014-12-10 02:31:40
【问题描述】:

我想为这些标记中的每一个添加一个 onClick,因此我无法为每个标记打开一个新活动,这可能是一组标记吗?

由于某种原因,它不允许我发布我的代码,有什么建议吗?

【问题讨论】:

    标签: java android google-maps marker


    【解决方案1】:

    没有任何代码很难帮助您查看您在做什么,但是...

    它的工作方式是你有一个 GoogleMap 对象,就像这样

    private GoogleMap mMap;
    

    然后你打电话给

    mMap.setOnMarkerClickListener(someObject);
    

    其中 someObject 是实现 OnMarkerClickListener 的类的实例,这意味着它具有这样的方法。

    @Override
    public boolean onMarkerClick(Marker marker) {
        // identify the marker you want and then do what ever you think should be done
        // for example when you added the marker, you could have given it a unique title
        // which you can check of here using
        if (marker.getTitle.equals("blah") {
           // do something
        } else {
           // do something else
        }
        return true;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-06
      • 1970-01-01
      相关资源
      最近更新 更多