Francesco Cariaggi Francesco Cariaggi - 2 months ago 23
Android Question

Android "custom" Spinner

What I need to achieve is a

Spinner
with these properties:


  • The
    Spinner
    allows the user to select from a fixed set of strings. Those strings are localized, so an English user has different choices than a French user.

  • When I try to retrieve the value of the selected item of the
    Spinner
    , I don't want it to return the localized value of that selected item, but rather the "non-localized" one (in my case, the English value of that string).



How could I achieve this kind of thing? Would a custom
Adapter
suffice? I've been stucking here for a while.

Answer

Ok, a custom Adapter was sufficient to do the trick. I've also defined a layout resource (for elements in the spinner) containing two TextViews: one with visibility="Visible" and one with visibility="Gone". The former holds the localized value, while the latter holds the english value.