Hi all, I'm not quite sure if this is a bug with Xamarin or if I'm just doing something stupid here. Basically I was trying to inherit from RelativeLayout and overriding GenerateLayoutParams (IAttributeSet attrs). Minimal, more or less auto generated example:
public class MyCustomLayout : Android.Widget.RelativeLayout
{
public override Android.Views.ViewGroup.LayoutParams GenerateLayoutParams (Android.Util.IAttributeSet attrs)
{
return base.GenerateLayoutParams (attrs);
}
public MyCustomLayout (Android.Content.Context context) : base (context)
{
}
public MyCustomLayout (Android.Content.Context context, Android.Util.IAttributeSet attrs) : base (context, attrs)
{
}
public MyCustomLayout (Android.Content.Context context, Android.Util.IAttributeSet attrs, int defStyle) : base (context, attrs, defStyle)
{
}
}
The Problem here is the returntype. If I try to compile the above I get an error complaining that the return type in the generated Java code has the wrong type for generateLayoutParams(android.util.AttributeSet), with ViewGroup.LayoutParams found and widget.RelativeLayout.LayoutParams required.
The actual error message: ...\obj\Debug\android\src\hewa\MyCustomLayout.java(45,45): Error: generateLayoutParams(android.util.AttributeSet) in hewa.MyCustomLayout cannot override generateLayoutParams(android.util.AttributeSet) in android.widget.RelativeLayout; attempting to use incompatible return type found : android.view.ViewGroup.LayoutParams required: android.widget.RelativeLayout.LayoutParams public android.view.ViewGroup.LayoutParams generateLayoutParams (android.util.AttributeSet p0)
On a side note, overridingpublic override Android.Views.ViewGroup.LayoutParams GenerateLayoutParams (ViewGroup.LayoutParams p)
doesn't cause errors.
Also this problem exists with all the ViewGroup derived Layouts.
So, am I doing something wrong here ?