Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Android ListView Custom ViewCell Bug - System.ObjectDisposedException

$
0
0

Hey,

My app is crashing on Android and not on iOS.

Here is the listview that is causing the error:

<ListView x:Name="HolidaysList" ItemsSource="{Binding Holidays}" RowHeight="48" VerticalOptions="FillAndExpand" IsVisible="{Binding NotLoading}">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <local:CheckBoxViewCell Text="{Binding Name}" Command="{Binding Path=BindingContext.ToggleHoliday, Source={x:Reference Root}}}" CommandParameter="{Binding .}" IsSelected="{Binding Checked}"/>
                    </DataTemplate>
                </ListView.ItemTemplate>
                <!--<x:Arguments>
                    <ListViewCachingStrategy>RecycleElement</ListViewCachingStrategy>
                </x:Arguments>-->
            </ListView>

<?xml version="1.0" encoding="UTF-8"?>
<ViewCell xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Talento.CheckBoxViewCell">
    <ViewCell.View>
        <StackLayout Orientation="Horizontal" Style="{DynamicResource EventLayoutStyle}">
            <Label x:Name="Label" Text="{Binding Text}" Style="{DynamicResource EventLabelStyle}" HorizontalOptions="Start"/>
            <Label x:Name="CheckboxLabel" IsVisible="{Binding IsSelected}" Text="✓" Style="{DynamicResource EventLabelStyle}" HorizontalOptions="EndAndExpand"/>
        </StackLayout>
    </ViewCell.View>
</ViewCell>

Here is the stack trace:

at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00030] in /Users/builder/data/lanes/3511/501e63ce/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.cs:153
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00002] in /Users/builder/data/lanes/3511/501e63ce/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:37
  at Android.Widget.TextView.set_TextFormatted (Java.Lang.ICharSequence value) [0x0001e] in /Users/builder/data/lanes/3511/501e63ce/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Widget.TextView.cs:2844
  at Android.Widget.TextView.set_Text (System.String value) [0x00013] in /Users/builder/data/lanes/3511/501e63ce/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Widget.TextView.cs:2855
  at Xamarin.Forms.Platform.Android.LabelRenderer.UpdateText () [0x00087] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\LabelRenderer.cs:211
  at Xamarin.Forms.Platform.Android.LabelRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x000c5] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\LabelRenderer.cs:115
  at (wrapper delegate-invoke) <Module>:invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
  at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x0000a] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:137
  at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:379
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.BindableObject+SetValueFlags attributes, System.Boolean silent) [0x000f4] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:581
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.BindableObject+SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0014b] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:378
  at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x001f9] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:173
  at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:55
  at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__47_0 () [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:542
  at Java.Lang.Thread+RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/3511/501e63ce/source/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36
  at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in /Users/builder/data/lanes/3511/501e63ce/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Java.Lang.IRunnable.cs:81
  at (wrapper dynamic-method) System.Object:257ed723-ff85-471a-8152-725febaa0ef3 (intptr,intptr)

Cannot access a disposed object.
Object name: 'Xamarin.Forms.Platform.Android.FormsTextView'.

I've read a few forum posts about adding CachingStrategy="RecycleElement" to the list view. This fixes Android, but causes unwanted behaviour on iOS - extra duplicate cells are generated. Scrolling seems to alleviate this iOS issue, but this is not a solution.

Does anyone have any insights into how I might be incorrectly implementing this? Other people seem to have this issue with images, but my custom viewcell is rather simple.

I'm running Xamarin Form 2.3.3.168. I upgraded to 2.3.3.180 but this did not fix anything either.

Thanks for your time.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>