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

加了 header 奔溃可能性很大 IndexOutOfBoundsException #46

Closed
wuyongx opened this issue Jun 1, 2016 · 9 comments
Closed

加了 header 奔溃可能性很大 IndexOutOfBoundsException #46

wuyongx opened this issue Jun 1, 2016 · 9 comments

Comments

@wuyongx
Copy link

wuyongx commented Jun 1, 2016

java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position 21(offset:21).state:22

@CymChad
Copy link
Owner

CymChad commented Jun 1, 2016

你用的是那种adapter?

@CymChad
Copy link
Owner

CymChad commented Jun 1, 2016

是最新的版本吗?

@wuyongx
Copy link
Author

wuyongx commented Jun 1, 2016

嗯。最新版。线性布局 header。

@CymChad
Copy link
Owner

CymChad commented Jun 1, 2016

是多布局的吗?

@CymChad
Copy link
Owner

CymChad commented Jun 1, 2016

还有就是你最好把crash的所有日志贴出来看看

@wuyongx wuyongx closed this as completed Jun 1, 2016
@wuyongx
Copy link
Author

wuyongx commented Jun 1, 2016

单一布局的

 private void setupRecyclerView(RecyclerView recyclerView) {
    Context context = recyclerView.getContext();
    recyclerView.hasFixedSize();
    recyclerView.setLayoutManager(new LinearLayoutManager(context));

    adapter =
        new BaseQuickAdapter<CreditClientInfo>(context, R.layout.client_card_progress_item, null) {
          @Override protected void convert(BaseViewHolder helper, CreditClientInfo info) {
            helper.setText(R.id.tv_in_date, info.ACCEPT_DATE);
            helper.setText(R.id.tv_receive_date, info.RECEIVE_DATE_TIME);
            helper.setText(R.id.tv_client_name, info.CLIENT_NAME);
            helper.setText(R.id.tv_card_status, info.APPLICATION_STATUS);
          }
        };
    //item 进入动画
    adapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_BOTTOM);
    recyclerView.setAdapter(adapter);
    //加载更多监听
    adapter.setOnLoadMoreListener(this);
    adapter.openLoadMore(PAGE_SIZE, true);
    //item 点击监听
    adapter.setOnRecyclerViewItemClickListener(this);
    adapter.setOnRecyclerViewItemChildClickListener(this);
    //添加头部
    headerView.setVisibility(View.VISIBLE);
    adapter.addHeaderView(headerView);
    //调用重新layout
    recyclerView.setAdapter(adapter);
  }

@CymChad
Copy link
Owner

CymChad commented Jun 1, 2016

把完整的crash贴出来。

@wuyongx
Copy link
Author

wuyongx commented Jun 1, 2016

谢谢。回复真快。

java.lang.IndexOutOfBoundsException
Inconsistency detected. Invalid item position 21(offset:21).state:22
android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4659)
android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4617)
android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1994)
android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1390)
android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1353)
android.support.v7.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1180)
android.support.v7.widget.LinearLayoutManager.scrollVerticallyBy(LinearLayoutManager.java:1031)
android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:4061)
android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
android.view.Choreographer.doCallbacks(Choreographer.java:670)
android.view.Choreographer.doFrame(Choreographer.java:603)
android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
android.os.Handler.handleCallback(Handler.java:739)
android.os.Handler.dispatchMessage(Handler.java:95)
android.os.Looper.loop(Looper.java:148)
android.app.ActivityThread.main(ActivityThread.java:5466)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)

@CymChad
Copy link
Owner

CymChad commented Jun 1, 2016

这是RecyclerView的bug 具体可查看 #16

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

2 participants