Shlok Jhawar
Shlok Jhawar

Reputation: 287

Spinner methods (setSelection) not working for only one spinner in activity

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

Answers (1)

Ashish
Ashish

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

Related Questions