Reputation: 287
In my activity, I have two spinners. I have to set their selections based on certain values.
One of the spinners (gradeSpinner
) works fine. But the other, boardSpinner
, doesn't. None of its methods work, and I need setSelection
to work properly.
Java code: https://gist.github.com/shlokj/1254c3caeaf1e36786b6128462304cfe
Layout file: https://gist.github.com/shlokj/d0bacad8786b1449a6fbb680f005211b
Why doesn't one spinner work, while the other does?
Upvotes: 1
Views: 322
Reputation: 6919
Put your setSelection before setting adapter.
After seeing your code you forgot to put the second parameter of setSelection()
.
It accepts two selection setSelection(position in int, Boolean)
E.g.
setSelection(boardNumber - 7, true)
Upvotes: 1