Wednesday, 24 July 2013

Obtaining resources by numer of index instead resource id by TypedArray

While using resources as items in you listview or adapter, try store and load it from <_array> tag. You will avoid exceptions in case where apk in specific language has new items and in other not.

Now you can take resource by index, not by specific id.
arr = mCtx.getResources().obtainTypedArray( R.array.art_sounds_url);
mAudioRes = arr.getResourceId( resArrPosition, -1 );