简体   繁体   中英

Cannot create an instance of Android.Widget.ArrayAdapter`1[T] because Type.ContainsGenericParameters is true

When I run my application and it gets to this section of code breaks:

var Adapter_ = ArrayAdapter.CreateFromResource(this, Resource.Array.calibre_array, Android.Resource.Layout.SimpleSpinnerItem);

This is the error that it's throwing:

System.MemberAccessException Message=Cannot create an instance of Android.Widget.ArrayAdapter`1[T] because Type.ContainsGenericParameters is true.

You neeed to set a type ArrayAdapter<T> of items in your array. Set ArrayAdapter<string> if it's an array of string items, for example.

var Adapter_ = ArrayAdapter<string>.CreateFromResource(this, Resource.Array.calibre_array, Android.Resource.Layout.SimpleSpinnerItem);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM