[英]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.