I have a ListView showing names of countries. I have stored the names in strings.xml as a string-array called country_names.
In populating the ListView,
As one of the possibilities, you may store 2 different arrays in XML: string array and integer array, and then programmatically put them in the HashMap.
Definition of arrays:
- USA
- Russia
- 1
- 7
And code:
String[] countriesNames = getResources().getStringArray(R.array.countries_names);
int[] countriesCodes = getResources().getIntArray(R.array.countries_codes);
HashMap myMap = new HashMap();
for (int i = 0; i < countriesNames.length; i++) {
myMap.put(countriesNames[i], countriesCodes[i]);
}
It may be a file with any name. See this