I have setup Spinner with the layout below, and I wanted to get the value of the item selected, not the displayed text. Where does one pull out the value? Also will this work for pulling out values the layout below? Or do I need some other way to setup (value, displayText) pair? So I guess I need to know how to set it up so it has a value and also how in onItemSelected I would pull the value?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:paddingLeft="12dip">
<Spinner
android:id="@+id/viewSpin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:entries="@array/some_values"
android:prompt="@array/some_names"/>
</LinearLayout>
You resolve the Spinner instance in your activity class with findViewById and set an OnItemSelectedListener on it. Since you are populating the Spinner with some kind of Adapter, use the items that you constructed the Adapter with and the position of the selected item as reported back in the third parameter of OnItemSelectedListener’s onItemSelected method
http://developer.android.com/reference/android/widget/AdapterView.OnItemSelectedListener.html#onItemSelected%28android.widget.AdapterView%3C?%3E,%20android.view.View,%20int,%20long%29