Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java.lang.ArrayIndexOutOfBoundsException:长度=10;指数=-1;add(ArrayList.java:442);在View.dispatcheattachedtowindow_Java_Android_Arrayindexoutofboundsexception - Fatal编程技术网

java.lang.ArrayIndexOutOfBoundsException:长度=10;指数=-1;add(ArrayList.java:442);在View.dispatcheattachedtowindow

java.lang.ArrayIndexOutOfBoundsException:长度=10;指数=-1;add(ArrayList.java:442);在View.dispatcheattachedtowindow,java,android,arrayindexoutofboundsexception,Java,Android,Arrayindexoutofboundsexception,我遇到了一个异常(java.lang.ArrayIndexOutOfBoundsException:length=10;index=-1),但在类ArrayList.java中没有找到错误消息。我不知道如何引导这个异常,从我的代码、Android bug或多线程? 以下是例外情况的详细信息: java.lang.ArrayIndexOutOfBoundsException: length=10; index=-1 at java.util.ArrayList.add(ArrayList.java

我遇到了一个异常(java.lang.ArrayIndexOutOfBoundsException:length=10;index=-1),但在类ArrayList.java中没有找到错误消息。我不知道如何引导这个异常,从我的代码、Android bug或多线程? 以下是例外情况的详细信息:

java.lang.ArrayIndexOutOfBoundsException: length=10; index=-1
at java.util.ArrayList.add(ArrayList.java:442)
at android.view.View.dispatchAttachedToWindow(View.java:15873)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3072)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3079)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3079)
at android.view.ViewGroup.addViewInner(ViewGroup.java:4696)
at android.view.ViewGroup.addView(ViewGroup.java:4490)
at android.view.ViewGroup.addView(ViewGroup.java:4462)
at my code, like this: ((FrameLayout) mBannerView).addView(view, params);
这是我的代码片段:

// ui-thread
public void onRenderSuccess(View view, float width, float height) {
    if (mBannerView instanceof FrameLayout) {
        ((FrameLayout) mBannerView).addView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    }
}

提前感谢:)

您很可能正在尝试访问数组中不存在的索引,为了更好地回答您的问题,请在此处发布您的ArrayList.java类+您正在使用或访问ArrayTank You@Gaurav的代码,我的代码只是Framelayout.addView(),变量索引属于View.java,我的代码无法触及它。如果您注释掉
addView
调用,异常是否会消失?这是否回答了您的问题?没有人能在没有看到相关代码的情况下肯定地回答您的问题。不包括设置索引的过帐代码毫无帮助。