I am trying to get a stringArray resource with this code:
String continent = "europe";
getResources().getStringArray(R.array.continent);
If I type R.array.europe, its ok, but I want this to be dynamic, so I'm looking for a way to use my string variable here..
This is probably a simple java problem, but I'm quite a noob both in java and android programming, and I didn't find the answer..
Thanks in advance;
edit: so here is my complete onCreate Method, did I do something wrong?
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.second);
String continent = (String) getIntent().getExtras().getString("continent");
int holderint = getResources().getIdentifier(continent, "Array",
this.getPackageName());
String[] items = getResources().getStringArray(holderint);
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,
items));
}
I'm not sure about the defPackage part though...