1. Are you ready for the Galaxy S20? Here is everything we know so far!

Spinner problem

Discussion in 'Android Development' started by Maxxan, Aug 19, 2010.

  1. Maxxan

    Maxxan Lurker
    Thread Starter

    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?
     


  2. meskiukas

    meskiukas Newbie

    Why do you need the event to fire again? It's usually a good thing not to do work when nothing has changed.
     
  3. Maxxan

    Maxxan Lurker
    Thread Starter

    The first item is like an "Add items.." options, so when I select that I want to open an input dialog.
     
  4. blundell

    blundell Well-Known Member

    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
     
  5. Maxxan

    Maxxan Lurker
    Thread Starter

    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?
     
  6. meskiukas

    meskiukas Newbie

    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.
     
  7. Maxxan

    Maxxan Lurker
    Thread Starter

    Ok, that might be a good idea. :)

    But do you know how to create a context menu for a spinner item?
     
Loading...
Similar Threads - Spinner problem
  1. GabeTheGreat73
    Replies:
    4
    Views:
    449
  2. towertech
    Replies:
    0
    Views:
    463
  3. ShamusVW
    Replies:
    3
    Views:
    756
  4. Prashant Sontale
    Replies:
    0
    Views:
    302
  5. Prashant Sontale
    Replies:
    0
    Views:
    266
  6. Prashant Sontale
    Replies:
    2
    Views:
    471
  7. Mingi
    Replies:
    0
    Views:
    291
  8. AbdouMike
    Replies:
    2
    Views:
    2,153
  9. Mingi
    Replies:
    0
    Views:
    1,793
  10. Mingi
    Replies:
    1
    Views:
    1,767

Share This Page

Loading...