Previously I had a simple string-array that contained a URL it looked like
- http://www.goo
This is what I've done to accomplish something like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="menu_items">
<item>@array/menu_item_dashboard</item>
<item>@array/menu_item_index</item>
</array>
<array name="menu_item_dashboard">
<item>@drawable/transparent</item>
<item>Dashboard</item>
<item>home</item>
</array>
<array name="menu_item_index">
<item>@drawable/transparent</item>
<item>Title</item>
<item>index</item>
</array>
</resources>
And to access:
TypedArray menuResources = getResources().obtainTypedArray(R.array.menu_items);
TypedArray itemDef;
for (int i = 0; i < menuResources.length(); i++) {
int resId = menuResources.getResourceId(i, -1);
if (resId < 0) {
continue;
}
itemDef = getResources().obtainTypedArray(resId);
//itemDef.getDrawable(0)
//itemDef.getString(1)
//itemDef.getString(2)
}