Android: Creating a View class and setting it as the content view for the root activity crashes the Workbooks app
terrencejames opened this issue · comments
I have something like
public class SampleView : Android.Views.View
{
LinearLayout _layout;
public SampleView(Context context) : base(context)
{
_layout = new LinearLayout(context);
_layout.SetBackgroundColor(Color.Green);
}
}
Activity mainActivity = StartedActivities.First();
mainActivity.SetContentView(new SampleView(mainActivity));
I then got this error under the code block:
I thought I was doing something wrong, so I opened up the 2D-drawing.workbook example and I am also unable to run it as is:
HOWEVER, doing something like
var rootActivity = StartedActivities.First ();
var layout = new LinearLayout(rootActivity);
layout.SetBackgroundColor(Android.Graphics.Color.Aqua);
rootActivity.SetContentView(layout);
works perfectly fine.
I'm running Version 1.5 on an Android Oreo emulator.
Subclassing most Android types in a Workbook is impossible at this time (and for the foreseeable future). I'm sorry for the trouble. We understand this is a major missing feature for Android workbooks.
Previous discussions:
There is a lot of tooling work that happens in Xamarin.Android when you subclass a Java type. Java files have to be generated at build time. Doing this in a live Android app is not something we can currently support, and I am not aware of any workaround to make this work in Workbooks.
Thanks for the speedy reply @sandyarmstrong
Subclassing most Android types in a Workbook is impossible at this time (and for the foreseeable future). I'm sorry for the trouble. We understand this is a major missing feature for Android workbooks.
Previous discussions:
There is a lot of tooling work that happens in Xamarin.Android when you subclass a Java type. Java files have to be generated at build time. Doing this in a live Android app is not something we can currently support, and I am not aware of any workaround to make this work in Workbooks.