Spinner problem


Last Updated:

  1. Maxxan

    Maxxan Member This Topic's Starter

    Joined:
    Aug 19, 2010
    Messages:
    7
    Likes Received:
    0
    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?
     

    Advertisement
  2. meskiukas

    meskiukas Member

    Joined:
    Aug 20, 2010
    Messages:
    13
    Likes Received:
    1
    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 Member This Topic's Starter

    Joined:
    Aug 19, 2010
    Messages:
    7
    Likes Received:
    0
    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

    Joined:
    Apr 23, 2010
    Messages:
    125
    Likes Received:
    17
    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 Member This Topic's Starter

    Joined:
    Aug 19, 2010
    Messages:
    7
    Likes Received:
    0
    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 Member

    Joined:
    Aug 20, 2010
    Messages:
    13
    Likes Received:
    1
    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 Member This Topic's Starter

    Joined:
    Aug 19, 2010
    Messages:
    7
    Likes Received:
    0
    Ok, that might be a good idea. :)

    But do you know how to create a context menu for a spinner item?
     

Share This Page

Loading...