[DOTNET] ERROR: Unhandled Exception
[DOTNET] MESSAGE: Object reference not set to an instance of an object.
[DOTNET] STACKTRACE: at Microsoft.Maui.Controls.Compatibility.Platform.Android.CellFactory.GetCell(Cell item, View convertView, ViewGroup parent, Context context, View view)
[DOTNET] at Microsoft.Maui.Controls.Compatibility.Platform.Android.TableViewModelRenderer.GetView(Int32 position, View convertView, ViewGroup parent)
[DOTNET] at ColoredTableViewRenderer.CustomHeaderTableViewModelRenderer.GetView(Int32 position, View convertView, ViewGroup parent) in ColoredTableViewRenderer.cs:line 72
[DOTNET] at Android.Widget.BaseAdapter.n_GetView_ILandroid_view_View_Landroid_view_ViewGroup_(IntPtr jnienv, IntPtr native__this, Int32 position, IntPtr native_convertView, IntPtr native_parent) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net8.0/android-34/mcw/Android.Widget.BaseAdapter.cs:line 548
[DOTNET] at Android.Runtime.DynamicMethodNameCounter.10(IntPtr , IntPtr , Int32 , IntPtr , IntPtr )
**System.NullReferenceException:** 'Object reference not set to an instance of an object.'
Steps to Reproduce
Call TableViewModelRenderer.GetView() in a class derived from TableViewRenderer.
The sample program is below:
using AView = Android.Views.View;
using AListView = Android.Widget.ListView;
using Android.Content;
using Android.Views;
using Microsoft.Maui.Controls.Compatibility.Platform.Android;
namespace App.Droid
{
[Obsolete]
public class ColoredTableViewRenderer : TableViewRenderer
{
public ColoredTableViewRenderer (Context context)
:base(context)
{
}
protected override TableViewModelRenderer
GetModelRenderer (AListView listView, TableView view)
{
return new CustomHeaderTableViewModelRenderer (Context, listView, view);
}
private class CustomHeaderTableViewModelRenderer : TableViewModelRenderer
{
public CustomHeaderTableViewModelRenderer (Context context, AListView listView, TableView view)
:base (context, listView, view)
{
}
public override AView GetView (int position, AView convertView,
ViewGroup parent)
{
var view = base.GetView (position, convertView, parent); // <--- Exception!!!
// ... Any Logic
return view;
}
}
}
}
Description
I have the following exception:
Steps to Reproduce
Call TableViewModelRenderer.GetView() in a class derived from TableViewRenderer. The sample program is below:
Link to public reproduction project repository
none
Version with bug
8.0.3 GA
Is this a regression from previous behavior?
No, this is something new
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Not version dependent
Did you find any workaround?
Unknown/Other
Relevant log output