Hi all,
I have a problem using the Android "Spinner". I put an objects collection
into that component:
List<Article> myList = ... ;
var sp = View.FindViewById<Spinner>(id);
var adapter = new ArrayAdapter<Article>(View.Context,
Android.Resource.Layout.SimpleSpinnerItem);
adapter.AddAll(myList);
sp.Adapter = adapter;
When the user choose the right object (displayed thanks the ToString()
method of Article), I try to get back the selected object with :
var sp = View.FindViewById<Spinner>(id);
Article myArticle;
myArticle = (Article)(object)sp.SelectedItem;
I get the following exception:
System.InvalidCastException: Cannot cast from source type to destination
type.
You should know that my class Article inherits from a CSObject<T, int> which
is an object coming from the VICI CoolStorage project. And the CSObject
implementes the following interfaces IEquatable<CSObject>, ISerializable,
INotifyPropertyChanged.
Any idea?
Thanks
Hugo
--
View this message in context:
http://mono-for-android.1047100.n5.nabble.com/Android-Spinner-Cannot-cast-from-source-type-to-destination-type-tp5711855.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid