Reputation: 85
I have an ArrayAdapter
being populated with ints
from a while
loop, we will say from 3 to 18. These numbers are put into a Spinner
.
My question is: is it possible to have a given number, say 8, be automatically selected?
EDIT: Changed checked to selected
Upvotes: 0
Views: 82
Reputation: 13154
First you have to find out the position of this number in your ArrayAdapter
(e.g. 8):
int pos = myAdapter.getPosition(8);
Then just set selection:
mySpinner.setSelection(pos);
Upvotes: 2