Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a workaround to the OnItemSelectedListener bug?

Tags:

android

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.

like image 392
Yevgeny Simkin Avatar asked Feb 28 '11 22:02

Yevgeny Simkin


3 Answers

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.

like image 75
CommonsWare Avatar answered Oct 22 '22 00:10

CommonsWare


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. :)

like image 34
Kevin Coppock Avatar answered Oct 21 '22 22:10

Kevin Coppock


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.

like image 40
RivieraKid Avatar answered Oct 21 '22 23:10

RivieraKid