I have a number of arrays stored in Strings.xml file in my android project. I want to populate a list from these Arrays based upon a button click. depends upon which button clicked, i need to populate different lists. So the code is very messy by adding a nested if else structure. Is there any way to get the String Array from the Strings.xml where i can call it using a single common method for all. I am keeping the same name for button tag and array name. please help....`
current code is
if(submit_button.getTag().toString.equalsIgnoreCase("vacation"){
return getResources().getStringArray(R.array.vacation);
}
else if(submit_button.getTag().toString.equalsIgnoreCase("summer"){
return getResources().getStringArray(R.array.summer);
}
else if(submit_button.getTag().toString.equalsIgnoreCase("monsoon"){
return getResources().getStringArray(R.array.monsoon);
}
else if(submit_button.getTag().toString.equalsIgnoreCase("automn"){
return getResources().getStringArray(R.array.automn);
}
else if(submit_button.getTag().toString.equalsIgnoreCase("rainy"){
return getResources().getStringArray(R.array.rainy);
}
else if(submit_button.getTag().toString.equalsIgnoreCase("humid"){
return getResources().getStringArray(R.array.humid);
}
else if(submit_button.getTag().toString.equalsIgnoreCase("sunny"){
return getResources().getStringArray(R.array.sunny);
}
else{
return null;
}