Xamarin表单配置的Textview [英] Xamarin Forms Disposed Textview

查看:49
本文介绍了Xamarin表单配置的Textview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Xamarin Forms Project(android)中经常遇到此异常.问题在于,堆栈跟踪几乎没有提供有关如何重现或在何处发生的信息.

Been getting this exception a lot in my Xamarin Forms Project (android). The problem is that the stacktrace gives little information on how to reproduce, or where does it occur.

Xamarin caused by: android.runtime.JavaProxyThrowable: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Xamarin.Forms.Platform.Android.FormsTextView'.
Java.Interop.JniPeerMembers.AssertSelf(IJavaPeerable self)<be2616b5140e4cbb8821649c795cfe62>:0
Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeNonvirtualVoidMethod(string encodedMember, IJavaPeerable self, JniArgumentValue* parameters)<be2616b5140e4cbb8821649c795cfe62>:0
Android.Widget.TextView.set_TextFormatted(ICharSequence value)<ec6bb63c41624773b5cc1eb2222982af>:0
Android.Widget.TextView.set_Text(string value)<ec6bb63c41624773b5cc1eb2222982af>:0
Xamarin.Forms.Platform.Android.LabelRenderer.UpdateText()<d572ae0ccf89437fad1de1370c623a06>:0
Xamarin.Forms.Platform.Android.LabelRenderer.OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)<d572ae0ccf89437fad1de1370c623a06>:0
<Module>.invoke_void_object_PropertyChangedEventArgs(object, PropertyChangedEventArgs)(wrapper delegate-invoke)
Xamarin.Forms.BindableObject.OnPropertyChanged(string propertyName)<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.Element.OnPropertyChanged(string propertyName)<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, BindableObject.BindablePropertyContext context, object value, bool currentlyApplying, BindableObject.SetValueFlags attributes, bool silent)<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, object value, BindableObject.SetValueFlags attributes, BindableObject.SetValuePrivateFlags privateAttributes)<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.BindingExpression.ApplyCore(object sourceObject, BindableObject target, BindableProperty property, bool fromTarget)<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.BindingExpression.Apply(object sourceObject, BindableObject target, BindableProperty property)<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.Binding.Apply(object newContext, BindableObject bindObj, BindableProperty targetProperty)<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.BindableObject.ApplyBindings(object oldContext, bool skipBindingContext)<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.BindableObject.ApplyBindings(object oldContext)<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.BindableObject.SetInheritedBindingContext(BindableObject bindable, object value)<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.Element.SetChildInheritedBindingContext(Element child, object context)<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.Element.OnBindingContextChanged()<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.View.OnBindingContextChanged()<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.BindableObject.SetInheritedBindingContext(BindableObject bindable, object value)<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.Element.SetChildInheritedBindingContext(Element child, object context)<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.Element.OnBindingContextChanged()<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.Cell.OnBindingContextChanged()<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.BindableObject.BindingContextPropertyBindingPropertyChanged(BindableObject bindable, object oldvalue, object newvalue)<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, BindableObject.BindablePropertyContext context, object value, bool currentlyApplying, BindableObject.SetValueFlags attributes, bool silent)<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, object value, BindableObject.SetValueFlags attributes, BindableObject.SetValuePrivateFlags privateAttributes)<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.BindableObject.SetValue(BindableProperty property, object value, bool fromStyle, bool checkAccess)<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.BindableObject.SetValue(BindableProperty property, object value)<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.BindableObject.set_BindingContext(object value)<7b0368eb3d0f405da776a09e3171532a>:0
Xamarin.Forms.TemplatedItemsList<TView, TItem>.<UnhookItem>d__140.MoveNext()<7b0368eb3d0f405da776a09e3171532a>:0
System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(object state)<67dcc9194d6a4f4f97ac27121b4304c3>:0
System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, object state, bool preserveSyncCtx)<67dcc9194d6a4f4f97ac27121b4304c3>:0
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, object state, bool preserveSyncCtx)<67dcc9194d6a4f4f97ac27121b4304c3>:0
System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()<67dcc9194d6a4f4f97ac27121b4304c3>:0
System.Threading.ThreadPoolWorkQueue.Dispatch()<67dcc9194d6a4f4f97ac27121b4304c3>:0
System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()<67dcc9194d6a4f4f97ac27121b4304c3>:0

推荐答案

此问题主要是由于ListView中的TextView/TextField引起的.如果您的情况相同,则可以将 CachingStrategy 更改为 RecycleElement .

This issues mostly occur because of TextView / TextField inside ListView. If you have the same case you can change the CachingStrategy to RecycleElement.

示例:

 <ListView x:Name="AccountDetailsList"
                        StyleId="AccountDetailsListID"
                        CachingStrategy="RecycleElement"
                        ItemsSource="{Binding AccountDetails}"

这篇关于Xamarin表单配置的Textview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆