I have an issue with the Spinner in Android. Selecting an item from the dropdown will adjust the offset of that dropdown the next time it is opened. So for example if I choose item 100 in a 500 item dropdown, the next time I open the dropdown, item 100 will be at the top of the list. This is the behaviour I want.
There seems to be an issue when I combine the selector functionality with calling setSelection(int)
. With the following steps I seem to have broken the offset system on dropdown spinners.
- Open the Spinner and select the second item.
- Open the Spinner again and this time dismiss it without selecting anything.
- Call
setSelection(int)
on the Spinner with a value greater than 2. - Open the Spinner a third time. Note that the offset is the same as back in Step 1.
I've taken a look at the code in Spinner and AdapterView, but I can't see anything public calls that I've missed. Is this a bug in Spinner or a bug in my code?