Issue
I am working on an android project and I am using a spinner which uses an array adapter which is populated from the database.
I can't find out how I can set the selected item programmatically from the list. For example if, in the spinner I have the following items:
- Category 1
- Category 2
- Category 3
How would I programmatically make Category 2 the selected item when the screen is created. I was thinking it might be similar to c# I.E Spinner.SelectedText = "Category 2" but there doesn't seem to be any method similar to this for Android.
Solution
Use the following:
spinnerObject.setSelection(INDEX_OF_CATEGORY2)
.
Answered By - Arun George
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.