OverlayItem does derive from Java.Lang.Object. Maybe you saw this declaration in Mono.Android.GoogleMaps.dll in the assembly browser and thought this "Object" is System.Object? (which is actually Java.Lang.Object):
> public class OverlayItem : Object Atsushi Eno > OK I have made a small test project you can look at. > > The compiler complains about CreateItem in MyItemizedOverlay. > > https://github.com/Cheesebaron/MonoDroid.TestOverlayItem > > As I understand it OverlayItem (Something that comes with Mono for > Android) is supposed to implement Java.Lang.Object. But it does not! > Because as you said it has a using System; decleration along with a > using Java.Lang; declaration, so the OverlayItem : Object is > ambiguous. > > On Tue, Dec 6, 2011 at 1:48 PM, Tomasz Cielecki<[email protected]> wrote: >> Or wait I was a bit quick there. >> >> Give me a moment and I will make a test project for you to see what is >> happening. >> >> On Tue, Dec 6, 2011 at 1:45 PM, Tomasz Cielecki<[email protected]> >> wrote: >>> OK, that seems a bit strange to me. Your suggestion works though. I >>> would have though that the OverlayItem would explicitly be >>> implementing Java.Lang.Object rather than just Object so that it would >>> be unambiguous. >>> >>> Maybe someone should make a note about this somewhere so that people >>> do not make the same mistake as I did. >>> >>> On Tue, Dec 6, 2011 at 1:35 PM, Atsushi Eno >>> <[email protected]> wrote: >>>> Ah, no that's not a bug :) >>>> You likely have "using System;" on top of your source and that binds >>>> "Object" class to System.Object type. Unlike "java.lang" package for >>>> Java compilers, C# compiler does not import "Java.Lang" by default, so >>>> you have to explicitly write "using Java.Lang;" . >>>> >>>> However, if you do that, C# compiler will error it out because "Object" >>>> name is now ambiguous between "System.Object" and "Java.Lang.Object". >>>> So, you will either have to give up using "using" statement or add >>>> explicit declaration that "using Object = Java.Lang.Object;" . >>>> >>>> Atsushi Eno >>>> >>>>> So the OverlayItem is having the using Java.Lang; in the top of the >>>>> file and is implementing Object, but then the compiler thinks it is >>>>> System.Object rather than Java.Lang.Object. I guess this is a bug that >>>>> you will have to correct. >>>>> >>>>> Meanwhile I am just using >>>>> >>>>> protected override Java.Lang.Object CreateItem(int index) >>>>> { >>>>> return overlayItems.ElementAt(index); >>>>> } >>>>> >>>>> Which seems to work fine. >>>>> >>>>> I have created a bug report: >>>>> http://bugzilla.xamarin.com/show_bug.cgi?id=2358 >>>>> >>>>> On Tue, Dec 6, 2011 at 11:55 AM, Atsushi Eno >>>>> <[email protected]> wrote: >>>>>> Yes, as the error message tells, it must be derived from >>>>>> Java.Lang.Object. >>>>>> >>>>>> Atsushi Eno >>>>>> >>>>>>> Is this because Overlay item is inheriting from System.Object rather >>>>>>> than Java.Lang.Object? >>>>>>> >>>>>>> public class OverlayItem : Object >>>>>>> >>>>>>> On Tue, Dec 6, 2011 at 9:45 AM, Tomasz Cielecki<[email protected]> >>>>>>> wrote: >>>>>>>> I get the same error even if CreateItem returns OverlayItem. So >>>>>>>> something is wrong somewhere. >>>>>>>> >>>>>>>> On Tue, Dec 6, 2011 at 9:43 AM, Tomasz Cielecki<[email protected]> >>>>>>>> wrote: >>>>>>>>> OK. About that OverlayItem. I have a Custom overlay item which looks >>>>>>>>> like this: >>>>>>>>> >>>>>>>>> class NMTOverlayItem : OverlayItem >>>>>>>>> { >>>>>>>>> private float[] color; >>>>>>>>> >>>>>>>>> public NMTOverlayItem(GeoPoint point, String title, String >>>>>>>>> snippet, float[] color) >>>>>>>>> : base(point, title, snippet) >>>>>>>>> { >>>>>>>>> this.color = color; >>>>>>>>> } >>>>>>>>> >>>>>>>>> public float[] Color >>>>>>>>> { >>>>>>>>> get { return color; } >>>>>>>>> } >>>>>>>>> } >>>>>>>>> >>>>>>>>> Now in the itenized overlay I have the CreateItem method: >>>>>>>>> >>>>>>>>> protected override NMTOverlayItem CreateItem(int index) >>>>>>>>> { >>>>>>>>> return overlayItems.ElementAt(index); >>>>>>>>> } >>>>>>>>> >>>>>>>>> I get the following error: >>>>>>>>> >>>>>>>>> 'NSPublic.AndroidClient.NMTItemizedOverlay.CreateItem(int)': return >>>>>>>>> type must be 'Java.Lang.Object' to match overridden member >>>>>>>>> 'Android.GoogleMaps.ItemizedOverlay.CreateItem(int)' >>>>>>>>> >>>>>>>>> Any ideas as to why this is happening? >>>>>>>>> >>>>>>>>> On Mon, Dec 5, 2011 at 6:52 PM, Tomasz >>>>>>>>> Cielecki<[email protected]> wrote: >>>>>>>>>> Awesome, will give it a go tomorrow :-) >>>>>>>>>> >>>>>>>>>> As always good job on the new release! >>>>>>>>>> >>>>>>>>>> On Dec 5, 2011 5:38 PM, "Jonathan Pryor"<[email protected]> >>>>>>>>>> wrote: >>>>>>>>>>> On Dec 5, 2011, at 11:25 AM, Tomasz Cielecki wrote: >>>>>>>>>>>> Due to changes to how sensors work, i.e. stuff being moved into >>>>>>>>>>>> SensorTypes the samples on GitHub do not work anymore. >>>>>>>>>>> Changes needed to get the samples working with the new release were >>>>>>>>>>> done >>>>>>>>>>> on the release-2-0 branch, which was just merged to master ~10 >>>>>>>>>>> minutes ago. >>>>>>>>>>> Please update your repo and see if that fixes it. :-) >>>>>>>>>>> >>>>>>>>>>>> Also there has been some changes in the ItemizedOverlay now having >>>>>>>>>>>> the >>>>>>>>>>>> CreateItem method registered, but it needs to return a >>>>>>>>>>>> Java.Lang.Object, does that mean that my custom OverlayItem has to >>>>>>>>>>>> inherit from Java.Lang.Object? I thought OverlayItem was already a >>>>>>>>>>>> Java.Lang.Object? >>>>>>>>>>> OverlayItem inherits Java.Lang.Object, so your class inheriting from >>>>>>>>>>> OverlayItem will also inherit Java.Lang.Object, just not directly. >>>>>>>>>>> >>>>>>>>>>> Subclassing OverlayItem is fine (and required, iirc). >>>>>>>>>>> >>>>>>>>>>>> Is there a list of changes made in the newest release somewhere? >>>>>>>>>>> http://android.xamarin.com/Releases/Mono_for_Android_4/Release_4.0.0#API_Changes >>>>>>>>>>> >>>>>>>>>>> - Jon >>>>>>>>>>> >>>>>>>>>>> _______________________________________________ >>>>>>>>>>> Monodroid mailing list >>>>>>>>>>> [email protected] >>>>>>>>>>> >>>>>>>>>>> UNSUBSCRIBE INFORMATION: >>>>>>>>>>> http://lists.ximian.com/mailman/listinfo/monodroid >>>>>>>>> -- >>>>>>>>> Med Venlig Hilsen / With Best Regards >>>>>>>>> Tomasz Cielecki >>>>>>>>> http://ostebaronen.dk >>>>>>>> -- >>>>>>>> Med Venlig Hilsen / With Best Regards >>>>>>>> Tomasz Cielecki >>>>>>>> http://ostebaronen.dk >>>>>> _______________________________________________ >>>>>> Monodroid mailing list >>>>>> [email protected] >>>>>> >>>>>> UNSUBSCRIBE INFORMATION: >>>>>> http://lists.ximian.com/mailman/listinfo/monodroid >>>>> >>>> _______________________________________________ >>>> Monodroid mailing list >>>> [email protected] >>>> >>>> UNSUBSCRIBE INFORMATION: >>>> http://lists.ximian.com/mailman/listinfo/monodroid >>> >>> >>> -- >>> Med Venlig Hilsen / With Best Regards >>> Tomasz Cielecki >>> http://ostebaronen.dk >> >> >> -- >> Med Venlig Hilsen / With Best Regards >> Tomasz Cielecki >> http://ostebaronen.dk > > _______________________________________________ Monodroid mailing list [email protected] UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid
