Yevgeny Simkin
Yevgeny Simkin

Reputation: 28349

Is there a workaround to the OnItemSelectedListener bug?

I suspect the answer is no, but thought I'd ask...

I have a Spinner that needs to reveal a hidden "proceed" button when the user has made a selection. However, since the OnItemSelectedListener is fired when the spinner is first rendered, and since it doesn't fire again when the user re-selects the item that is already highlighted, there doesn't appear to be a way to use this event to reveal a hidden button (or really do anything) contingent on the user having made a selection.

Is there some alternative way to do this? AdapterView has a ClickListener which just throws an exception, so that's a non-starter. And it doesn't seem to have any other notification scheme for when the user first makes contact with it, or when it closes... unless I'm missing something? (wouldn't be the first time).

All help appreciated.

Upvotes: 6

Views: 2595

Answers (3)

CommonsWare
CommonsWare

Reputation: 1006799

I have a Spinner that needs to reveal a hidden "proceed" button when the user has made a selection.

The user has always made a selection. There is no concept of a Spinner without a selection. Hence, do not hide the "proceed" button.

Upvotes: 2

Kevin Coppock
Kevin Coppock

Reputation: 134664

I know that this isn't a solution, per se, but from the sound of things, it is a requirement that the user select SOMETHING to be allowed to continue, correct? What if you add, as the first item in the spinner, an unrelated item, saying something like "Please Select One..."? Have that as the default chosen item, then the user will have to make a different selection to continue, hence, the listener will be fired.

Just a thought. :)

Upvotes: 2

RivieraKid
RivieraKid

Reputation: 5961

I've seen in an few answer here on stackoverflow that onNothingSelected will enable you to detect this.

That answer was the only one and wasn't accepted, and I haven't tried it myself, but give it a go and see what happens.

Upvotes: 1

Related Questions