Skip to content

Instantly share code, notes, and snippets.

@dodola
Created April 4, 2013 14:10
Show Gist options
  • Save dodola/5310669 to your computer and use it in GitHub Desktop.
Save dodola/5310669 to your computer and use it in GitHub Desktop.
Android 获取数组资源中的值
Resources res=getResources();
TypedArray icons =res.obtainTypedArray(R.array.icons);
Drawable drawable1=icons.getDrawable(0);
Drawable drawable2=icons.getDrawable(1);
Drawable drawable3=icons.getDrawable(2);
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="icons">
<item>@drawable/image1</item>
<item>@drawable/image2</item>
<item>@drawable/image3</item>
</string-array>
</resources>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment