On Dec 7, 2011, at 4:01 AM, laurar81 wrote:
> In OnCreate find the mapview1 but the cast MapView is invalid exception:
>
> MapView mapView = (MapView)FindViewById(Resource.Id.mapview1)
>
> This is the errore message:
>
> Message "Cannot cast from source type to destination type." string
Third party .jar support is still in flux. Specifically, we're not currently
registering the Java <-> C# type mapping, so FindViewById() is returning an
Android.Views.View instance, not a MapView instance.
You can work around this in two ways. The simpler way is to use the
FindViewById<T>() method:
MapView mapView = FindViewById<MapView>(Resource.Id.mapview1);
Alternatively, you can use the Android.Runtime.Extensions.JavaCast<T>()
extension method:
MapView mapView =
FindViewById(Resource.Id.mapview1).JavaCast<MapView>();
Thanks,
- Jon
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid