Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onMeasure ArrayIndexOutOfBoundsException 索引越界 #1574

Open
wangtao2855 opened this issue Jul 12, 2024 · 2 comments
Open

onMeasure ArrayIndexOutOfBoundsException 索引越界 #1574

wangtao2855 opened this issue Jul 12, 2024 · 2 comments

Comments

@wangtao2855
Copy link

采用的是最新版本,报错基本堆栈如下,他并非常出现,

  1. Caused by: java.lang.ArrayIndexOutOfBoundsException: length=3; index=3
  2. at android.util.ContainerHelpers.binarySearch(ContainerHelpers.java:28)
  3. at android.util.SparseArray.get(SparseArray.java:131)
  4. at android.util.SparseArray.get(SparseArray.java:122)
  5. at android.view.View.getTag(View.java:25605)
  6. at com.scwang.smart.refresh.layout.SmartRefreshLayout.onMeasure(SmartRefreshLayout.java:43)
  7. at android.view.View.measure(View.java:25894)
  8. at androidx.constraintlayout.widget.ConstraintLayout$h.h(ConstraintLayout.java:551)
  9. at androidx.constraintlayout.core.widgets.a.y0(ConstraintWidgetContainer.java:279)
  10. at androidx.constraintlayout.core.widgets.a.Y(ConstraintWidgetContainer.java:131)

对应代码
@OverRide
protected void onMeasure(final int widthMeasureSpec,final int heightMeasureSpec) {
int minimumWidth = 0;
int minimumHeight = 0;
final View thisView = this;
final boolean needPreview = thisView.isInEditMode() && mEnablePreviewInEditMode;

    for (int i = 0, len = super.getChildCount(); i < len; i++) {
        View child = super.getChildAt(i);

        if (child.getVisibility() == GONE || "GONE".equals(child.getTag(R.id.srl_tag))) {
            continue;
        }

辛苦协助解决下。

@wangtao2855
Copy link
Author

@scwang90 辛苦尽快解决下 或提供下解决方案 感谢

@wangtao2855
Copy link
Author

我其实也不太理解这段

    if (child.getVisibility() == GONE || "GONE".equals(child.getTag(R.id.srl_tag))) {
        continue;
    }
    中GONE".equals(child.getTag(R.id.srl_tag) 他的作用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant