android - Retrieving the bound value of a spinner -



want selected value of spinner.
first, created string-array in res/values/string

<string-array name="location">     <item name="auh">abu dhabi</item>     <item name="aan">al ain</item>     <item name="dmm">dammam</item> </string-array> 

spinner definition in layout:

<spinner          android:id="@+id/spnorigin"          android:layout_width="fill_parent"          android:layout_height="wrap_content"           android:entries="@array/location"/> 

now need complete button click body, if user selects abu dhabhi, should return auh.
getselectitem returns abu dhabi, not value behind this. if try this, can approach allow me name attribute?

string[] _location =getresources().getstringarray(r.array.location); 

button handler:

bttprocess.setonclicklistener(new view.onclicklistener() {               public void onclick(view v) {      }); 

i don't believe name attribute valid on items of string array.

i think best bet set array have values in it. can ((adapterview)getviewbyid(r.id.spnorigin)).getselecteditemposition() relevant name other array.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -