I am still learning Java. I have this XML string-array list:
<string-array name="CountryCodes" >
<item>93,AF, Afganistan</item>
<item>355,AL, Albania</item>
<item>213,DZ, Algeria</item>
</string-array>
I am using an Arrayadapter to add this array to a spinner like this:
String [] countries = this.getResources().getStringArray(R.array.CountryCodes);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, countries);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mCountries.setAdapter(adapter);
This works just fine, no problems with the XML, but what I really want to do is to display only the country in the spinner and then display the corresponding digits in a separate Edittext .
I know I have to use the split() method to remove the ",". but once I have the individual string element (example "93,AF, Afganistan")
How do I
- get just the country name
- keep the country name in sync with the corresponding digits