Forum Xamarin.Android

Conversion Error in Putting Parcelable Data Type in Intent

JacksonSwensonJacksonSwenson USMember
edited May 2015 in Xamarin.Android

I am attempting to make a list of clients, which is a custom class that i wrote and implemented the parcelable functions in order to pass it between activities but im getting a build error on conversion when calling intent.PutParcelableArrayListExtra

My class prototype is
class Client : Java.Lang.Object, IParcelable

I instantiate the list with
IList<Client> clients = new List<Client>()

And i then add two values to the list but then when i try to put it into the intent with
intent.PutParcelableArrayListExtra("clientList", clientList);

I get the error
error CS1503: Argument 2: cannot convert from 'System.Collections.Generic.IList<Core.Client>' to 'System.Collections.Generic.IList<Android.OS.IParcelable>'

So i try to cast
intent.PutParcelableArrayListExtra("clientList", (IList<Parcelable>)clientList);

But i get this error
error CS1503: Argument 2: cannot convert from 'System.Collections.Generic.IList<Android.OS.Parcelable>' to 'System.Collections.Generic.IList<Android.OS.IParcelable>'

And it is my only error. Any help would be greatly appreciated! I'm new to Xamarin and Android development entirely and i'm in no way and expert in c#, so it could most likely be a very trivial mistake.

Tagged:

Answers

Sign In or Register to comment.