简体   繁体   English

无法在使用其他方法定义的内部类中引用非最终变量pcurl1

[英]Cannot refer to a non-final variable pcurl1 inside an inner class defined in a different method

Doing an Application whcoh displays Markers on a Google Maps Fragment and opens a link in a browser on click, but i have a single marker where i dont want this to happen. 进行应用程序时,在Google Maps Fragment上显示标记,并在单击时在浏览器中打开链接,但是我有一个标记,我不希望发生这种情况。

GoogleMap mMap;
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.fragment1)).getMap();
mMap.addMarker(new MarkerOptions()
    .position(new LatLng(lat3, lng3))
    .snippet(bud1)
    .title(name1));
mMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
    @Override
    public void onInfoWindowClick(Marker marker) {
        Uri uriUrl = Uri.parse(pcurl1);
        Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl);
        startActivity(launchBrowser);
    }
});

Now i want to implement a if (.... != "Your Position") in the onInfoWindowClick() but I have no Idea how to check the Marker for this content inside the marker. 现在,我想在onInfoWindowClick()实现if (.... != "Your Position") ,但我不知道如何检查标记中此内容的标记。

Edit: New Problem occured which is "Cannot refer to a non-final variable pcurl1 inside an inner class defined in a different method" and if I set it final it destroys it's funktion becasue it is set inside a loop. 编辑:出现了新问题,即“无法在用不同方法定义的内部类中引用非最终变量pcurl1”,如果我将其最终设置为它会破坏它的功能,因为它是在循环内设置的。

addMarker method returns a Marker object. addMarker方法返回一个Marker对象。 For your location marker, save if as a field eg myLocationMarker and in the callback do 对于您的位置标记,将if保存为字段,例如myLocationMarker并在回调中执行

if (!marker.equals(myLocationMarker)) {
    // ...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法以不同方法定义的内部类中引用非最终变量LinearLayout - Cannot refer to a non-final variable LinearLayout inside an inner class defined in a different method 无法在以其他方法定义的内部类中引用非最终变量lblNewLabel - Cannot refer to a non-final variable lblNewLabel inside an inner class defined in a different method 不能在不同方法中定义的内部类中引用非final变量str - 如何解决这个问题? - Cannot refer to a non-final variable str inside an inner class defined in a different method - How to fix this? 不能在不同方法中定义的内部类中引用非最终变量名 - Cannot refer to a non-final variable name inside an inner class defined in a different method Android-无法在以其他方法定义的内部类中引用非最终变量测试 - Android - Cannot refer to a non-final variable test inside an inner class defined in a different method 不能在不同方法中定义的内部类中引用非final变量i - Cannot refer to a non-final variable i inside an inner class defined in a different method 出现错误“无法在用其他方法定义的内部类中引用非最终变量” - Getting error “Cannot refer to a non-final variable inside an inner class defined in a different method” 类型无法引用用其他方法定义的内部类中的非最终变量Asortiment - Type Cannot refer to a non-final variable Asortiment inside an inner class defined in a different method “不能引用在不同方法中定义的内部类中的非最终变量buttonflag” - “Cannot refer to a non-final variable buttonflag inside an inner class defined in a different method” 不能在不同方法中定义的内部类中引用非最终变量 - Cannot refer to a non-final variable inside an inner class defined in a different method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM