Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IndexOutOfBounds on Spinner?

I have a problem with interpretation of stack trace.. The peoblem is that there is no class from my package and so it is hard for me to find out what is happening.. As I fallowed trace, I think it's about an adapter and spinner, but on that page I have 6 spinners, I debug them all and didn't find anything weird (like selectedItemPosition or something)..

Maybe someone had similar problem? Here's th trace. If you need some code, tell me

    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)

I don't know what to do..

like image 376
Seraphis Avatar asked Apr 29 '11 15:04

Seraphis


1 Answers

See if you have setSelection() called on any of the spinners that may have index that greater than the spinner's adapter size. e.g. if your spinner has two items, and if you call setSelection(2), this will result in IndexOutOfBoundsException exception.

like image 62
azgolfer Avatar answered Sep 30 '22 07:09

azgolfer