Skip to content
This repository was archived by the owner on Apr 18, 2026. It is now read-only.
This repository was archived by the owner on Apr 18, 2026. It is now read-only.

java.lang.ArrayIndexOutOfBoundsException: length=10; index=-1 #630

@lmvpintonextbitt

Description

@lmvpintonextbitt

Issues and steps to reproduce

I have an issue with a flexbox. I have this code on oncreate the activity

          _cfWoStatusList.HasFixedSize = false;
           _llManagerWoStatusList = new FlexboxLayoutManager(Context);
           _llManagerWoStatusList.FlexDirection = FlexDirection.Row;
           _llManagerWoStatusList.FlexWrap = FlexWrap.Wrap;
           _llManagerWoStatusList.JustifyContent = JustifyContent.FlexStart + JustifyContent.SpaceAround;
           _llManagerWoStatusList.AlignItems = AlignItems.FlexStart + AlignContent.SpaceAround;
           _llManagerWoStatusList.AutoMeasureEnabled = true;
           _cfWoStatusList.SetLayoutManager(_llManagerWoStatusList);

           FlexboxItemDecoration itemDecoration = new FlexboxItemDecoration(Context);
           itemDecoration.SetOrientation(FlexboxItemDecoration.Horizontal);
           itemDecoration.SetDrawable(Context.GetDrawable(Resource.Drawable.flexbox_divider_horizontal));
           _cfWoStatusList.AddItemDecoration(itemDecoration);

           _cfWoStatusItems = new List<CfWoStatusGrpModel>();
           var _woUtils = new WoUtils();
           _adapterWoStatusGrp = new DashboardWoStatusGrpAdapter(Screen.CurrentFragment, _cfWoStatusItems, _woUtils);
           _cfWoStatusList.SetAdapter(_adapterWoStatusGrp);

Somethimes, I have this error java.lang.ArrayIndexOutOfBoundsException: length=10; index=-1
 at com.google.android.flexbox.FlexboxLayoutManager.getPositionToFlexLineIndex(FlexboxLayoutManager.java:2565)
 at com.google.android.flexbox.FlexboxItemDecoration.isFirstItemInLine(FlexboxItemDecoration.java:288)
 at com.google.android.flexbox.FlexboxItemDecoration.setOffsetAlongMainAxis(FlexboxItemDecoration.java:155)
 at com.google.android.flexbox.FlexboxItemDecoration.getItemOffsets(FlexboxItemDecoration.java:116)

I poupalte the list of itens on one adapter
                   _cfWoStatusItems.Clear();
                    _cfWoStatusList.SetItemViewCacheSize(response.Result.Count);
                    _adapterWoStatusGrp.NotifyDataSetChanged();
                    _cfWoStatusItems.AddRange(response.Result);
                    _adapterWoStatusGrp.NotifyItemRangeInserted(_cfWoStatusItems.Count, response.Result.Count);
                    _adapterWoStatusGrp.NotifyDataSetChanged();

Can you help me?

## Expected behavior
*Please describe what you expected would happen.*

## Version of the flexbox library
FlexboxLayout.Xamarin.Android nugget 3.0.0

## Link to code
*Please link to the code we can use to reproduce this issue.*
*A complete project we can build/run is preferred, if you can't provide one, please show*
*us relevant code*

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions