为了账号安全,请及时绑定邮箱和手机立即绑定

我想问一下这是什么意思?为什么会报错?

10-05 22:36:46.341 20189-20189/com.mengmengda.gridview E/AndroidRuntime: FATAL EXCEPTION: main
                                                                         Process: com.mengmengda.gridview, PID: 20189
                                                                         java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mengmengda.gridview/com.mengmengda.gridview.MainActivity}: java.lang.ArrayIndexOutOfBoundsException: length=10; index=10
                                                                             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2330)
                                                                             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
                                                                             at android.app.ActivityThread.access$800(ActivityThread.java:154)
                                                                             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
                                                                             at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                             at android.os.Looper.loop(Looper.java:135)
                                                                             at android.app.ActivityThread.main(ActivityThread.java:5273)
                                                                             at java.lang.reflect.Method.invoke(Native Method)
                                                                             at java.lang.reflect.Method.invoke(Method.java:372)
                                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
                                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
                                                                          Caused by: java.lang.ArrayIndexOutOfBoundsException: length=10; index=10
                                                                             at com.mengmengda.gridview.MainActivity.getData(MainActivity.java:45)
                                                                             at com.mengmengda.gridview.MainActivity.onCreate(MainActivity.java:36)
                                                                             at android.app.Activity.performCreate(Activity.java:6041)
                                                                             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1109)
                                                                             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2283)
                                                                             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2392)
                                                                             at android.app.ActivityThread.access$800(ActivityThread.java:154)
                                                                             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
                                                                             at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                             at android.os.Looper.loop(Looper.java:135)
                                                                             at android.app.ActivityThread.main(ActivityThread.java:5273)
                                                                             at java.lang.reflect.Method.invoke(Native Method)
                                                                             at java.lang.reflect.Method.invoke(Method.java:372)
                                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
                                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)

循环代码

public List<Map<String,Object>> getData() {
   for (int i=0;i<icon.length;i++) {
       Map<String, Object> map = new HashMap<String, Object>();
       map.put("image",icon[i]);
       map.put("text",iconName[i]);
       dataList.add(map);
   }
   return dataList;
}

正在回答

1 回答

少写了一个String数组。。。

1 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Android攻城狮的第二门课(第1季)
  • 参与学习       111161    人
  • 解答问题       1457    个

本课程由浅入深地带您学会Android的常用控件的开发和使用

进入课程

我想问一下这是什么意思?为什么会报错?

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信