ArrayIndexOutOfBoundException

时间:2012-02-17 10:20:07

标签: android android-layout

在我的应用程序中,我正在创建一个数据库,当我单击“发送”按钮时,它应该被插入到数据库中。对于第一个记录,它没有显示任何错误,但是当我插入更多时,强制关闭,出现以下异常:

02-17 15:38:56.480: WARN/dalvikvm(10538): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538): FATAL EXCEPTION: main
02-17 15:38:56.500: ERROR/AndroidRuntime(10538): java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 4
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at java.util.Vector.elementAt(Vector.java:329)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at com.A_PJTMANAGER.pkg.A_PJTMANAGERact$EfficientAdapter.getView(A_PJTMANAGERact.java:174)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.widget.AbsListView.obtainView(AbsListView.java:1315)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.widget.ListView.makeAndAddView(ListView.java:1727)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.widget.ListView.fillDown(ListView.java:652)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.widget.ListView.fillFromTop(ListView.java:709)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.widget.ListView.layoutChildren(ListView.java:1580)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.widget.AbsListView.onLayout(AbsListView.java:1147)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.view.View.layout(View.java:7035)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.widget.RelativeLayout.onLayout(RelativeLayout.java:909)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.view.View.layout(View.java:7035)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.widget.RelativeLayout.onLayout(RelativeLayout.java:909)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.view.View.layout(View.java:7035)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.view.View.layout(View.java:7035)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.view.View.layout(View.java:7035)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.view.View.layout(View.java:7035)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.view.ViewRoot.performTraversals(ViewRoot.java:1045)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.os.Looper.loop(Looper.java:123)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at android.app.ActivityThread.main(ActivityThread.java:4627)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at java.lang.reflect.Method.invokeNative(Native Method)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at java.lang.reflect.Method.invoke(Method.java:521)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-17 15:38:56.500: ERROR/AndroidRuntime(10538):     at dalvik.system.NativeStart.main(Native Method)`

1 个答案:

答案 0 :(得分:0)

at java.util.Vector.elementAt(Vector.java:329)

logcat中的这个错误意味着你正在使用Vector,当从vector获取值时,index是更高的矢量大小