Hi Alex,
It sounds like you might be making a simple thing complicated.  You
want to use two parallel arrays, one array for the keys that display
in the spinner and the second array for the numerical values when one
of the keys is selected.  Put the keys and values in the correct order
so the index will match up.  Maybe I misunderstand but it seems like a
straightforward case where you can access the correct value by reading
the position from the spinner key when there is a click event on the
spinner.

With regards to your request for information on layouts... I found
this web page with a bunch of the layouts from Android 1.5 to be very
helpful:
http://svn.jetbrains.org/idea/BRANCHES/MaiaM1/bundled/android/testData/sdk1.5/platforms/android-1.5/data/res/layout/

Regards,
Beth

On Sep 3, 6:56 am, Justin Anderson <janderson....@gmail.com> wrote:
> 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 <demers.a...@gmail.com> wrote:
>
> > Anyone knows how to? Am I being clear?
>
> > On Aug 20, 8:48 pm, AlexDemers <demers.a...@gmail.com> 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 android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to