Jedním přístupem by bylo uložení výkresů v strings.xml jako pole řetězců něco takového:
<string-array name="location_flags">
<item>@drawable/ic_image_name</item>
<item>@drawable/ic_image_name</item>
<item>@drawable/ic_image_name</item>
<item>@drawable/ic_image_name</item>
<item>@drawable/ic_image_name</item>
<item>@drawable/ic_image_name</item>
<item>@drawable/ic_image_name</item>
</string-array>
Poté načtěte toto pole v kódu aktivity:
TypedArray locationFlags=getResources().obtainTypedArray(R.array.location_flags);
Potom použitím smyčky for můžete získat Drawable něco takového:
for(int i=0i<locationFlags.length();i++)
{
Drawable drawable = locationFlags.getResourceId(i, -1);
}
Po použití TypedArray nezapomeňte recyklovat, protože jde o sdílený zdroj:
locationFlags.recycle();