Note that there are some explanatory texts on larger screens.

plurals
  1. POInflating a Generic/Templated Custom View
    text
    copied!<p>Is it possible to inflate a custom/subclassed view that is templated ?</p> <p>That is, can the following be inflated:</p> <pre><code>public class TextViewT&lt;T&gt; : TextView { List&lt;T&gt; _list; public TextViewT(Context context) : base(context) { } public TextViewT(Context context, IAttributeSet attributes) : base(context, attributes) { } } </code></pre> <p>If so, what is the syntax in the layout file for such a type ?</p> <p>Specifically, how would the absolute class name <code>app.droid.views.custom.TextViewT</code> appear ?</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;app.views.custom.TextViewT xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text_view_t" android:layout_width="match_parent" android:layout_height="match_parent"&gt; </code></pre> <p>I get the following exception when attempting to do so:</p> <pre><code>UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'App.Droid.Views.Custom.TextViewT, App.Droid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. at System.Type.GetType (string,bool) &lt;0x00027&gt; at Java.Interop.TypeManager.n_Activate (intptr,intptr,intptr,intptr,intptr,intptr) &lt;0x00057&gt; at (wrapper native-to-managed) Java.Interop.TypeManager.n_Activate (intptr,intptr,intptr,intptr,intptr,intptr) &lt;0x0006f&gt; at (wrapper delegate-invoke) &lt;Module&gt;.invoke_void__this___intptr_intptr_intptr_intptr_JValue[] (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) &lt;0x000cb&gt; at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) &lt;0x00067&gt; at Android.App.Activity.SetContentView (int) &lt;0x001d7&gt; at App.Droid.Views.CalendarView.Render () &lt;0x00073&gt; at MonoCross.Droid.MXActivityView`1&lt;App.ViewModels.CalendarVM&gt;.OnCreate (Android.OS.Bundle) &lt;0x00243&gt; at App.Droid.Views.CalendarView.OnCreate (Android.OS.Bundle) &lt;0x0001b&gt; at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) &lt;0x00057&gt; at (wrapper dynamic-method) object.cb51fcb8-c099-4fce-b266-642090f4d778 (intptr,intptr,intptr) &lt;0x00043&gt; </code></pre> <p>Thank you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload