• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Spinner problem

Maxxan

Lurker
Hi!
I've got a problem when trying to catch the selection of a spinner list item. I've added an OnItemSelectedListener, but it is only fired when a NEW item in the list is selected, not when the same item is selected that was selected before. How do I catch that event?

Example: Spinner has values A, B, and C, value A is selected by default. If I click the spinner and select A again in the list, OnItemSelectedListener is not fired. But I A is selected and I select B or C in the list, OnItemSelectedListener is fired.

How do I notice if A is selected again in the list?
 
You could: When option A is selected open your dialog and set the spinner to (none selected, d selected) so as if they click A again your onClick will fire
 
What I tried now was to create a custom adapter, and set the onClick listner for the first view. But if I do it like that, the list is never closed when clicking on the first item.

Is is possible to programatically close the list?
 
IMHO, you should reconsider having the "Add new item" selected by default, and have the user explicitly press if, if they need to add a new item. If something already is selected, the user won't know that he has to click on it again. So I would either have it selected by default, and have your code that deals with the form submission to see this, and show the dialog, or add a new item, which would be name "Please choose...", or something like that. You will end up with an application that is easier to use.
 
Back
Top Bottom