xamarin - 如何解决 Xamarin.Forms.Platform.Android.ListViewAdapter.IsEnabled 异常?

标签 xamarin exception xamarin.forms xamarin.android

我有一个包含一些用户选择的项目的列表。我的 CustumCellViewTemplate 有一个“取消选择”控件,可以从列表中删除单元格。 当列表完全充满项目时,“取消选择”控件起作用,但是当我想删除最后一个项目或者最后一个项目出现在 ListView 中时,我得到了这个异常:

"System.NullReferenceException: Object reference not set to an instance of an object.
at Xamarin.Forms.Platform.Android.ListViewAdapter.IsEnabled (System.Int32 position) [0x0002a] in D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\ListViewAdapter.cs:413 
at Android.Widget.BaseAdapter.n_IsEnabled_I (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 position) [0x00008] in <263adecfa58f4c449f1ff56156d886fd>:0 
at (wrapper dynamic-method) System.Object.389216aa-a260-49e0-aaaa-e4e2031ad22f(intptr,intptr,int)"

这是我的配置:

Mono 8.1
Xamarin.Forms 3.3.0.893527-pre3
Xamarin.Android.Support.Design 27.0.2.1
Xamarin.Android.Support.v7.AppCompat 27.0.2.1
Xamarin.Android.Support.v4 27.0.2.1
Xamarin.Android.Support.v7.CardView 27.0.2.1
Xamarin.Android.Support.v7.MediaRouter 27.0.2.1
Xamarin.GooglePlayServices.Location 60.1142.1
Xamarin.GooglePlayServices.Maps 60.1142.1
Xamarin.Essentials 0.10.0-preview

请问您知道如何解决这个问题吗?

问候

最佳答案

您现在可能已经解决了您的问题,但请将其留在这里供其他遇到此问题的人使用。

感谢 Jason 的问题,它引导我清理了对 ListView 逻辑的可绑定(bind)项源的操作。我做了很多我不需要做的 .Clear() 和 Add 操作。我减少了这些数量,它解决了我的问题。所以我会看看你是如何搞乱 ListView 的 ItemSource 的。

关于xamarin - 如何解决 Xamarin.Forms.Platform.Android.ListViewAdapter.IsEnabled 异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52783736/

相关文章:

ios - Xamarin Forms 检测屏幕是否处于事件状态和/或设备已锁定

xamarin - Xamarin Forms 中的 Android 占位符\提示文本

xamarin - Flutter 中的 Xamarin MessagingCenter 相当于什么?

c# - Xamarin 中不支持 PCL 配置文件

java - "no result exception"用于 Spring @Service 的

c# - 在 C# 中重复一个函数,直到它不再抛出异常

image - 具有相同 imageSource 的多个图像并不总是加载 (Xamarin)

c# - 如何在 Xamarin 中获取 GoogleApiClient 实例?

java - 无法从 Eclipse 查看 Tomcat 启动期间抛出的异常

c# - Xamarin Forms 相对布局不会堆叠