0

In Xamarin, I am modifying a class that was a standard Activity but is now a Map Fragment. The inherited Map Fragment is of type Android.Support.V4.App.Fragment.

Here is the previous code:

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;
}

This is the code I am working with:

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;
}

I am getting errors for both of the methods. This is the error:

Error CS0106: The modifier 'override' is not valid for this item

Can I have some help coding these functions?

Thanks in advance

Garry
  • 1,251
  • 9
  • 25
  • 45
  • Why you added `Android.Support.V4.App.Fragment.` to onResume and onPause methods? if you inherited your class from Fragment then no need to add this, may be that's why you have that error – choper Apr 07 '14 at 07:36

1 Answers1

0

If you're using fragments and the V4 Support Library you need to:

  • Install the Google Play Services (Gingerbread) or (Froyo) package
  • Your fragment should then inherit from SupportMapFragment
  • Make sure you're targeting API Level 8 in the Project Properties under the Application tab

Do not install the generic Google Play Services component, as it doesn't provide the SupportMapFragment

Then it should work.

mikescandy
  • 31
  • 7