I haven't tried using the spinner adapter yet, so I'm not sure, but it might
be possible to do the following:

- Create a new object that holds both the city string and the number
- Override the toString() method to return the city string
- Pass the array of your new object type to the spinner
- Then the spinner would return your object and you can get the number value
from that

Again, I don't know how the spinner adapter is set up exactly, but you might
be able to get something like this to work.

Hope that helps,
Justin

----------------------------------------------------------------------
There are only 10 types of people in the world...
Those who know binary and those who don't.
----------------------------------------------------------------------


On Thu, Sep 3, 2009 at 3:48 AM, AlexDemers <[email protected]> wrote:

>
> Anyone knows how to? Am I being clear?
>
> On Aug 20, 8:48 pm, AlexDemers <[email protected]> wrote:
> > Hey, I was wondering how to put a string array in a spinner (I can,
> > using the ArrayAdapter) but I also want to set keys for these also.
> > But it seems that there's no constructors for that (I may be
> > mistaken).
> >
> > I have 2 arrays: {"5123", "7434", "7333", "7345" } and {"City 1",
> > "City 2", "City 3", "City 4" }. Obviously, the spinner UI should show
> > the name array of the cities, but in the backend (what's returned from
> > the submission of the form is the value.
> >
> > Anyone knows how?
> >
> > // Put the array in the spinner
> > ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
> > android.R.layout.simple_spinner_item, cityNames);
> > spinCities.setAdapter(adapter);
> >
> > While, I'm the subject of spinners: is there any resource on the
> > internet describing every type of spinner layouts? I'm using
> > simple_spinner_item but I find it too small. Any suggestions?
> >
> > Thanks.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to