Handling Spinner Selections

After the Spinner control has been filled with data, you can control which item is selected by using the setSelection() method. For example, you know that the option for female gender is stored in the string array at index 2 (because you use a

0-based string array). Because you conveniently decide to map the indexes directly to the gender values, you can set the Spinner control to the Female option by using the setSelection() method, as follows: spinner.setSelection(2);

The Spinner class also includes a number of methods for retrieving the current item selected.

Was this article helpful?

0 0

Post a comment