android recyclerview滑动生成java.lang.IndexOutOfBoundsException:无效的索引

时间:2018-11-16 13:21:34

标签: android android-recyclerview

我正在使用recyclerview从左向右滑动列表中的编辑数据,但是它会生成java.lang.IndexOutOfBoundsException: Invalid index exception。这是错误日志。我用于其他片段的相同代码也可以正常工作。有人可以告诉我我哪里做错了吗?

错误日志:
---------崩溃开始

2018-11-16 17:33:14.446 12699-12699/com.example.avantika.queueadmin E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.avantika.queueadmin, PID: 12699
    java.lang.IndexOutOfBoundsException: Invalid index 7, size is 6
        at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
        at java.util.ArrayList.get(ArrayList.java:308)
        at android.widget.ArrayAdapter.getItem(ArrayAdapter.java:344)
        at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:397)
        at android.widget.ArrayAdapter.getView(ArrayAdapter.java:369)
        at android.widget.Spinner.makeView(Spinner.java:690)
        at android.widget.Spinner.layout(Spinner.java:638)
        at android.widget.Spinner.onLayout(Spinner.java:600)
        at android.view.View.layout(View.java:16652)
        at android.view.ViewGroup.layout(ViewGroup.java:5438)
        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
        at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
        at android.view.View.layout(View.java:16652)
        at android.view.ViewGroup.layout(ViewGroup.java:5438)
        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
        at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
        at android.view.View.layout(View.java:16652)
        at android.view.ViewGroup.layout(ViewGroup.java:5438)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
        at android.widget.ScrollView.onLayout(ScrollView.java:1525)
        at android.view.View.layout(View.java:16652)
        at android.view.ViewGroup.layout(ViewGroup.java:5438)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
        at android.view.View.layout(View.java:16652)
        at android.view.ViewGroup.layout(ViewGroup.java:5438)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
        at android.view.View.layout(View.java:16652)
        at android.view.ViewGroup.layout(ViewGroup.java:5438)
        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
        at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
        at android.view.View.layout(View.java:16652)
        at android.view.ViewGroup.layout(ViewGroup.java:5438)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
        at android.view.View.layout(View.java:16652)
        at android.view.ViewGroup.layout(ViewGroup.java:5438)
        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
        at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
        at android.view.View.layout(View.java:16652)
        at android.view.ViewGroup.layout(ViewGroup.java:5438)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
        at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2678)
        at android.view.View.layout(View.java:16652)
        at android.view.ViewGroup.layout(ViewGroup.java:5438)
        at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2176)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1936)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1112)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6035)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
        at android.view.Choreographer.doCallbacks(Choreographer.java:670)
        at android.view.Choreographer.doFrame(Choreographer.java:606)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5451)
        at java.lang

0 个答案:

没有答案