0
> 09-10 11:38:07.166: E/AndroidRuntime(11497): FATAL EXCEPTION: main
>     09-10 11:38:07.166: E/AndroidRuntime(11497): java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at java.util.ArrayList.get(ArrayList.java:311)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.widget.HeaderViewListAdapter.isEnabled(HeaderViewListAdapter.java:164)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.widget.ListView.dispatchDraw(ListView.java:3062)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.widget.ExpandableListView.dispatchDraw(ExpandableListView.java:233)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.View.draw(View.java:7093)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.widget.AbsListView.draw(AbsListView.java:2699)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.ViewGroup.drawChild(ViewGroup.java:1739)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.ViewGroup.drawChild(ViewGroup.java:1737)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.View.draw(View.java:6989)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.widget.FrameLayout.draw(FrameLayout.java:361)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.ViewGroup.drawChild(ViewGroup.java:1739)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.ViewGroup.drawChild(ViewGroup.java:1737)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.ViewGroup.drawChild(ViewGroup.java:1737)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.ViewGroup.drawChild(ViewGroup.java:1737)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.View.draw(View.java:6989)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.widget.FrameLayout.draw(FrameLayout.java:361)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.ViewGroup.drawChild(ViewGroup.java:1739)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.View.draw(View.java:6989)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.widget.FrameLayout.draw(FrameLayout.java:361)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.ViewGroup.drawChild(ViewGroup.java:1739)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1466)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.View.draw(View.java:6989)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.widget.FrameLayout.draw(FrameLayout.java:361)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1882)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.ViewRoot.draw(ViewRoot.java:1544)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.ViewRoot.performTraversals(ViewRoot.java:1280)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1882)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.os.Handler.dispatchMessage(Handler.java:99)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.os.Looper.loop(Looper.java:130)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at android.app.ActivityThread.main(ActivityThread.java:3701)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at java.lang.reflect.Method.invokeNative(Native Method)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at java.lang.reflect.Method.invoke(Method.java:507)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
>     09-10 11:38:07.166: E/AndroidRuntime(11497):  at dalvik.system.NativeStart.main(Native Method)

我得到了例外,但没有行号来指向我的班级。那么我怎样才能找到异常呢?感谢您的建议

4

4 回答 4

0

HeaderViewListAdapter.java:164

它显示您在 HeaderViewListAdapter.java 类的第 164 行有错误。

于 2012-09-10T08:50:10.023 回答
0

这里可能发生的事情是其中之一:

  • 您将数组传递给适配器,并在显示之前对其进行修改
  • 您覆盖您的适配器以返回与您的数组大小不匹配的 getCount() 值
于 2012-09-10T08:50:25.073 回答
0

在应用程序启动时设置一个断点,例如在 onCreate() 中,并以调试模式启动。不过,IndexOutOfBoundsException应该给您一些指导,例如,您在代码中的什么位置访问ArrayList对象的值?

于 2012-09-10T08:54:48.367 回答
-2

java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1 这意味着你的数组大小是1,你尝试获取数组[1]而不是数组[0]

请发送代码。

于 2012-09-10T08:58:03.650 回答