-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Bug] [Android] ArgumentOutOfRangeException in CollectionView: Adapter miscalculates item position when using CV Header #7243
Comments
* Move all the header/footer adjustment to IItemsViewSource fixes #7121 fixes #7102 partially implements #3172 fixes #7243 * Fix selection bugs introduced by header/footer on Android * Implement grouping for CollectionView on Android * Enable grouping tests for Android * Naming and comment cleanup * Update Xamarin.Forms.Platform.Android/CollectionView/ListSource.cs Co-Authored-By: Gerald Versluis <gerald.versluis@microsoft.com> * Update Xamarin.Forms.Platform.Android/CollectionView/ObservableGroupedSource.cs
* Move all the header/footer adjustment to IItemsViewSource fixes xamarin#7121 fixes xamarin#7102 partially implements xamarin#3172 fixes xamarin#7243 * Fix selection bugs introduced by header/footer on Android * Implement grouping for CollectionView on Android * Enable grouping tests for Android * Naming and comment cleanup * Update Xamarin.Forms.Platform.Android/CollectionView/ListSource.cs Co-Authored-By: Gerald Versluis <gerald.versluis@microsoft.com> * Update Xamarin.Forms.Platform.Android/CollectionView/ObservableGroupedSource.cs
* Move all the header/footer adjustment to IItemsViewSource fixes xamarin#7121 fixes xamarin#7102 partially implements xamarin#3172 fixes xamarin#7243 * Fix selection bugs introduced by header/footer on Android * Implement grouping for CollectionView on Android * Enable grouping tests for Android * Naming and comment cleanup * Update Xamarin.Forms.Platform.Android/CollectionView/ListSource.cs Co-Authored-By: Gerald Versluis <gerald.versluis@microsoft.com> * Update Xamarin.Forms.Platform.Android/CollectionView/ObservableGroupedSource.cs
It's back MAUI 8.0.6 , Android 8.1 System.Collections.Generic.List |
Confirm, the same for me: MAUI 8.0.20: System.Collections.Generic.List |
Description
When using the CollectionView in Xamarin.Forms 4.2 and using the new CV Header feature, the SelectableItemsViewAdapter seems to miscalculate the item positions.
This leads to unwanted behaviour (wrong item selections) and also to exceptions.
The issue exists since CollectionView Headers were introduced (so much love for this! :-)) for Android (which is XF4.2-pre1 I think).
As things run fine on iOS, I could not reproduce the error there. This is Android only.
I faced and reproduced this issue on an Huawei P Smart+ (2018) running Android 8.1. But a quick test on several Emulators gave me the same exception - so this is neither device-specific nor dependent on the OS version.
Steps to Reproduce
OR (easier)
Expected Behavior (in attached repo)
Actual Behavior (in attached repo)
StackTrace:
08-22 12:34:27.914 I/MonoDroid( 8272): UNHANDLED EXCEPTION: 08-22 12:34:27.973 I/MonoDroid( 8272): System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. 08-22 12:34:27.973 I/MonoDroid( 8272): Parameter name: index 08-22 12:34:27.973 I/MonoDroid( 8272): at System.Collections.Generic.List'1[T].get_Item (System.Int32 index) [0x00009] in <d4a23bbd2f544c30a48c44dd622ce09f>:0 08-22 12:34:27.973 I/MonoDroid( 8272): at Xamarin.Forms.Platform.Android.SelectableItemsViewAdapter.UpdateFormsSelection (System.Int32 adapterPosition) [0x00020] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\SelectableItemsViewAdapter.cs:138 08-22 12:34:27.973 I/MonoDroid( 8272): at Xamarin.Forms.Platform.Android.SelectableItemsViewAdapter.SelectableClicked (System.Object sender, System.Int32 adapterPosition) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\SelectableItemsViewAdapter.cs:125 08-22 12:34:27.973 I/MonoDroid( 8272): at Xamarin.Forms.Platform.Android.SelectableViewHolder.OnViewHolderClicked (System.Int32 adapterPosition) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\SelectableViewHolder.cs:51 08-22 12:34:27.973 I/MonoDroid( 8272): at Xamarin.Forms.Platform.Android.SelectableViewHolder.OnClick (Android.Views.View view) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\SelectableViewHolder.cs:40 08-22 12:34:27.973 I/MonoDroid( 8272): at Android.Views.View+IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v) [0x00011] in <b781ed64f1d743e7881ac038e0fbdf85>:0 08-22 12:34:27.973 I/MonoDroid( 8272): at (wrapper dynamic-method) System.Object.43(intptr,intptr,intptr)
Basic Information
Screenshots
No visual error detected
Reproduction Link
CVHeaderDemo.zip
The text was updated successfully, but these errors were encountered: