【问题标题】:setOnInfoWindowClickListener for a Marker标记的 setOnInfoWindowClickListener
【发布时间】:2014-09-18 06:39:24
【问题描述】:

我创建了一个名为“Pin”的标记,并试图在单击它的窗口时打开一个活动/类。 从我目前的情况来看,活动会打开,但是当点击任何标记的窗口时。

我想在点击标记 Pin 的窗口时打开它。

我想开的班级是“holyStone”。

private void holystone() 
    {

        // TODO Auto-generated method stub
        LatLng pos = new LatLng(52.972869, -9.427004);
        Marker Pin = theMap.addMarker(new MarkerOptions()

                .title("Holy Stone of Clonrichert")
                .snippet("Holy Stone of Clonrichert has been upgraded to a class two relic by the Vatican.")
                .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN))
                .position(pos)
                .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN))


        );
        // below displays the window...remove this!!!
        //Pin.showInfoWindow();

            Pin.isInfoWindowShown();
        this.theMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
            @Override
            public void onInfoWindowClick(Marker Pin) {
               Intent intent = new Intent(MainActivity.this, holyStone.class);
               startActivity(intent);
            }
        }); 

任何建议都会很棒,感谢您的关注。

【问题讨论】:

  • 你的描述不清楚,听起来有点矛盾。请说明活动窗口何时打开,何时不打开。
  • 对不起,我主要是想在点击Marker Pin的InfoWindow时打开holyStone.class。

标签: java android google-maps google-maps-markers


【解决方案1】:

我通过使用 if else 语句解决了这个问题。

我在开始时添加了标记,就在 onCreate 方法之前。

例如受保护的静态标记引脚 = null; protected static Marker Casino = null;

if(Casino.isInfoWindowShown()){
                   Intent intent = new Intent(MainActivity.this, TheRock.class);
                   startActivity(intent);

                    }

                    else if(Pin.isInfoWindowShown()){
                        Intent intent = new Intent(MainActivity.this, holyStone.class);

                        startActivity(intent);
                        }
                }

如果您对我的回答有任何疑问,请提出。 谢谢。

【讨论】:

    猜你喜欢
    • 2015-03-16
    • 1970-01-01
    • 1970-01-01
    • 2014-05-24
    • 1970-01-01
    • 1970-01-01
    • 2019-04-23
    • 2018-02-11
    • 2015-06-22
    相关资源
    最近更新 更多