The methods I used for my major project is to get the values from another
string array,
an example:
[The coding may be wrong as I currently don't have a eclipse software to
debug]
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private Spinner selectCountry;
private ArrayList<String> countryName = new ArrayList<String>();
private ArrayList<String> countryCode = new ArrayList<String>();
countryName.add("Alabama");
countryName.add("California");
countryCode.add("AL");
countryCode.add("CA");
ArrayAdapter spinnerArrayAdapter = new
ArrayAdapter(this,android.R.layout.simple_spinner_dropdown_item, countryName
);
selectCountry.setAdapter(spinnerArrayAdapter);
public void onCreate(Bundle savedInstanceState)
{
selectCountry.setOnItemSelectedListener(new
Spinner.OnItemSelectedListener()
{
public void onItemSelected(AdapterView<?>arg0, View arg1,int arg2,long arg3)
{
String storeCode = countryCode.getSelectedItemPosition();
}
});
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
you use countryName to display the country in the spinner, and when u
selected a country, it refers to the
value in the countryCode [the storeCode should be have the value of the
countryCode], because the
getSelectedItemPosition(); will point to the rows you have selected, hope
the rough idea helps.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en