android – Spinner上的IndexOutOfBounds?

前端之家收集整理的这篇文章主要介绍了android – Spinner上的IndexOutOfBounds?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我对堆栈跟踪的解释有一个问题.问题是我的包中没有类,所以我很难找出发生的事情.当我吞下踪迹时,我认为这是关于适配器和微调器,但在那个页面上我有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异常.
原文链接:https://www.f2er.com/android/314196.html

猜你在找的Android相关文章