首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何解决Xamarin.Forms.Platform.Android.ListViewAdapter.IsEnabled异常?

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

Stack Overflow用户
提问于 2018-10-13 00:40:44
回答 1查看 845关注 0票数 2

我有一个列表,里面有一些用户选择的项目。我的CustumCellViewTemplate有一个"unselect“控件,用于从列表中删除单元格。当列表完全被项目填满时,“取消选择”控件可以工作,但是当我想要删除最后一项或者如果最后一项出现在ListView中时,我会得到这样的异常:

代码语言:javascript
复制
"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)"

这是我的配置:

代码语言:javascript
复制
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

你知道怎么解决这个问题吗?

问候

EN

回答 1

Stack Overflow用户

发布于 2019-04-20 02:39:16

你现在可能已经解决了你的问题,但是把这个留给遇到这个问题的其他人吧。

感谢Jason的问题,它引导我清理了对列表视图逻辑的可绑定项源代码的操作。我做了很多.Clear(),并补充说我不需要这样做。我减少了这些的数量,它为我解决了这个问题。所以我将看看您是如何处理列表视图的ItemSource的。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52783736

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档