我对堆栈跟踪的解释有一个问题。问题是我的程序包中没有类,因此对我来说很难发现正在发生的事情。当我放弃跟踪时,我认为这与适配器和微调器有关,但在该页面上,我有6个微调器,我将它们全部调试完毕,没有发现任何奇怪的东西(例如selectedItemPosition之类的东西)。

也许有人遇到过类似的问题?
这是痕迹。如果您需要一些代码,请告诉我

    Uncaught handler: thread main exiting due to uncaught exception
    java.lang.IndexOutOfBoundsException
     at java.util.Arrays$ArrayList.get(Arrays.java:72)
     at android.widget.ArrayAdapter.getItem(ArrayAdapter.java:298)
     at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:351)
     at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
     at android.widget.AbsSpinner.onMeasure(AbsSpinner.java:198)
     at android.view.View.measure(View.java:7987)
     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3023)
     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:888)
     at android.widget.LinearLayout.measureVertical(LinearLayout.java:350)
     at android.widget.LinearLayout.onMeasure(LinearLayout.java:278)
     at android.view.View.measure(View.java:7987)
     at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:893)
     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
     at android.widget.ScrollView.onMeasure(ScrollView.java:276)
     at android.view.View.measure(View.java:7987)
     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3023)
     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:888)
     at android.widget.LinearLayout.measureVertical(LinearLayout.java:350)
     at android.widget.LinearLayout.onMeasure(LinearLayout.java:278)
     at android.view.View.measure(View.java:7987)
     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3023)
     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
     at android.view.View.measure(View.java:7987)
     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3023)
     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
     at android.view.View.measure(View.java:7987)
     at android.view.ViewRoot.performTraversals(ViewRoot.java:763)
     at android.view.ViewRoot.handleMessage(ViewRoot.java:1633)
     at android.os.Handler.dispatchMessage(Handler.java:99)
     at android.os.Looper.loop(Looper.java:123)
     at android.app.ActivityThread.main(ActivityThread.java:4363)
     at java.lang.reflect.Method.invokeNative(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:521)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:877)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:635)
     at dalvik.system.NativeStart.main(Native Method)

我不知道该怎么办..

最佳答案

查看是否在索引可能大于微调器的适配器大小的任何微调器上调用了setSelection()。例如如果微调器有两个项目,并且调用setSelection(2),则将导致IndexOutOfBoundsException异常。

10-08 18:32