These are the code I found in Android framework/base/core.
Here is the example.
First, the array.xml is below:
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <array name="lockscreen_targets_when_silent"> <item>@drawable/ima_btn</item> <item>@drawable/images</item> </array> </resources>Then, you can use these code to get the items from the array.
The parameter of the obtainTypedArray() is the array which you want to get the item from.
TypedArray typAry = getResources().obtainTypedArray(
R.array.lockscreen_targets_when_silent);
for (int i = 0; i < typAry.length(); i++) {
TypedValue value = typAry.peekValue(i);
Log.d(TAG, "get resourceId: " + value.resourceId + ",
get ResourceName: " + getResources().getResourceName(value.resourceId));
沒有留言:
張貼留言