Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/371.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
GeoCoder cuauses java.lang.IndexOutOfBoundsException:索引3无效,大小为3_Java_Android_Google Maps - Fatal编程技术网

GeoCoder cuauses java.lang.IndexOutOfBoundsException:索引3无效,大小为3

GeoCoder cuauses java.lang.IndexOutOfBoundsException:索引3无效,大小为3,java,android,google-maps,Java,Android,Google Maps,嗨,伙计们,我正在和地理编码器一起工作,以获取纬度和经度,但我的代码有时工作得很好,否则它会通过异常(即 java.lang.IndexOutOfBoundsException:索引3无效,大小为3 位于java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251) 获取(ArrayList.java:304) 在com.example.mine4.latitudelongitudecoverter.LatLangT

嗨,伙计们,我正在和地理编码器一起工作,以获取纬度和经度,但我的代码有时工作得很好,否则它会通过异常(即

java.lang.IndexOutOfBoundsException:索引3无效,大小为3
位于java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
获取(ArrayList.java:304)
在com.example.mine4.latitudelongitudecoverter.LatLangToLoCaTion$1.onClick上(LatLangToLoCaTion.java:70)
在android.view.view.performClick上(view.java:4222)
在android.view.view$PerformClick.run(view.java:17620)
位于android.os.Handler.handleCallback(Handler.java:800)
位于android.os.Handler.dispatchMessage(Handler.java:100)
位于android.os.Looper.loop(Looper.java:194)
位于android.app.ActivityThread.main(ActivityThread.java:5391)
位于java.lang.reflect.Method.Invokenactive(本机方法)
位于java.lang.reflect.Method.invoke(Method.java:525)
在com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run上(ZygoteInit.java:833)
位于com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)

在dalvik.system.NativeStart.main(Native Method)
中,这意味着传递的是无效的
索引3
,当
大小
3
时,基本上是从0开始索引,所以当数组或列表的大小为3时,您可以传递
0,1,2
索引以从数组或列表中获取值。现在,当您传递索引3时表示
IndexOutOfBoundsException
,您传递的索引不能超过其大小。要获得3个索引值
Array
List
大小应为
4
或更大。

由于某种原因,您的j变为3,大小为3,因此,当在for循环中时,它会中断

我想
maxResult
应该等于
addresses.size()
而不是5