在Xamarin中,我正在修改一个标准Activity
的类,但现在是Map Fragment
。继承的Map Fragment
属于Android.Support.V4.App.Fragment
。
以下是上一段代码:
protected override void OnPause()
{
base.OnPause();
// Pause the GPS - we won't have to worry about showing the
// location.
_map.MyLocationEnabled = false;
_map.InfoWindowClick -= HandleInfoWindowClick;
_map.MarkerClick -= HandleMarkerClick;
//_map.MarkerClick -= MapOnMarkerClick;
}
protected override void OnResume()
{
base.OnResume();
SetupMapIfNeeded();
_map.MyLocationEnabled = true;
_map.InfoWindowClick += HandleInfoWindowClick;
_map.MarkerClick += HandleMarkerClick;
// Setup a handler for when the user clicks on a marker.
//_map.MarkerClick += MapOnMarkerClick;
}
这是我正在使用的代码:
protected override void Android.Support.V4.App.Fragment.OnPause()
{
base.OnPause();
// Pause the GPS - we won't have to worry about showing the
// location.
_map.MyLocationEnabled = false;
_map.InfoWindowClick -= HandleInfoWindowClick;
_map.MarkerClick -= HandleMarkerClick;
//_map.MarkerClick -= MapOnMarkerClick;
}
protected override void Android.Support.V4.App.Fragment.OnResume()
{
base.OnResume();
SetupMapIfNeeded();
_map.MyLocationEnabled = true;
_map.InfoWindowClick += HandleInfoWindowClick;
_map.MarkerClick += HandleMarkerClick;
// Setup a handler for when the user clicks on a marker.
//_map.MarkerClick += MapOnMarkerClick;
}
我的两种方法都出错了。这是错误:
Error CS0106: The modifier 'override' is not valid for this item
我可以帮助编写这些函数吗?
提前致谢
答案 0 :(得分:0)
如果您正在使用片段和V4支持库,则需要:
SupportMapFragment
请勿安装通用Google Play服务组件,因为它不提供SupportMapFragment
然后它应该工作。