SilverWolfe
SilverWolfe

Reputation: 85

Another one concerning array adapters (android)

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

Answers (1)

Michał Klimczak
Michał Klimczak

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

Related Questions