{"id":1524,"date":"2012-09-08T22:51:12","date_gmt":"2012-09-08T14:51:12","guid":{"rendered":"http:\/\/leybreeze.com\/blog\/?p=1524"},"modified":"2012-09-08T22:51:12","modified_gmt":"2012-09-08T14:51:12","slug":"android%e4%b8%ad%e9%80%9a%e8%bf%87xml%e8%b5%84%e6%ba%90%e6%96%87%e4%bb%b6%e5%ae%9a%e4%b9%89%e6%95%b0%e7%bb%84","status":"publish","type":"post","link":"http:\/\/leybreeze.com\/blog\/?p=1524","title":{"rendered":"Android\u4e2d\u901a\u8fc7xml\u8d44\u6e90\u6587\u4ef6\u5b9a\u4e49\u6570\u7ec4"},"content":{"rendered":"<p>\u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a<\/p>\n<p><strong>\u5b57\u7b26\u4e32\u6570\u7ec4<\/strong><br \/>\nXML<\/p>\n<pre>&lt;string-array name=\"sample_names\"&gt;\r\n\t&lt;item&gt;foo&lt;\/item&gt;\r\n\t&lt;item&gt;bar&lt;\/item&gt;\r\n\t&lt;item&gt;baz&lt;\/item&gt;\r\n&lt;\/string-array&gt;<\/pre>\n<p>JAVA<\/p>\n<pre lang=\"JAVA\">String[] names = getResources().getStringArray(R.array.sample_names);<\/pre>\n<p><strong>\u6574\u5f62\u6570\u7ec4<\/strong><br \/>\nXML<\/p>\n<pre>&lt;integer-array name=\"sample_ids\"&gt;\r\n\t&lt;item&gt;1&lt;\/item&gt;\r\n\t&lt;item&gt;2&lt;\/item&gt;\r\n\t&lt;item&gt;3&lt;\/item&gt;\r\n&lt;\/integer-array&gt;<\/pre>\n<p>JAVA<\/p>\n<pre lang=\"JAVA\">int[] ids = getResources().getStringArray(R.array.sample_ids);<\/pre>\n<p><strong>Drawable \u6570\u7ec4<\/strong><br \/>\nXML<\/p>\n<pre>&lt;array name=\"sample_images\"&gt;\r\n\t&lt;item&gt;@drawable\/title&lt;\/item&gt;\r\n\t&lt;item&gt;@drawable\/logo&lt;\/item&gt;\r\n\t&lt;item&gt;@drawable\/icon&lt;\/item&gt;\r\n&lt;\/array&gt;<\/pre>\n<p>JAVA<\/p>\n<pre lang=\"JAVA\">TypedArray images = getResources().obtainTypedArray(R.array.sample_images);\r\nDrawable drawable = images.getDrawable(0);<\/pre>\n<p><strong>Color \u6570\u7ec4<\/strong><br \/>\nXML<\/p>\n<pre>&lt;array name=\"sample_colors\"&gt;\r\n\t&lt;item&gt;#FFFF0000&lt;\/item&gt;\r\n\t&lt;item&gt;#FF00FF00&lt;\/item&gt;\r\n\t&lt;item&gt;#FF0000FF&lt;\/item&gt;\r\n&lt;\/array&gt;<\/pre>\n<p>JAVA<\/p>\n<pre lang=\"JAVA\">TypedArray colors = getResources().obtainTypedArray(R.array.sample_colors);\r\nint color = colors.getColor(0,0);\/\/ \u53c2\u6570\u5206\u522b\u4e3a\u4e0b\u6807<\/pre>\n<p>\u8bf4\u660e\uff1aAndroid \u53ef\u4ee5\u901a\u8fc7 xml \u683c\u5f0f\u7684\u8d44\u6e90\u6587\u4ef6\u6765\u58f0\u660e\u4e0e\u5b9a\u4e49\u5404\u79cd\u7c7b\u578b\u7684\u6570\u7ec4\u3002\u8fd9\u6837\u505a\u7684\u597d\u5904\u5305\u62ec\u53ef\u4ee5\u6839\u636e\u4e0d\u540c\u8bed\u8a00\/\u786c\u4ef6\u89c4\u683c\u7b49\u6761\u4ef6\u5206\u914d\u4e0d\u540c\u7684\u6570\u7ec4\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee3\u7801\u4e0e\u8303\u4f8b\uff1a \u5b57\u7b26\u4e32\u6570\u7ec4 XML &lt;string-array name=&#8221;sample_names&#8221;&#038;g &hellip; <a href=\"http:\/\/leybreeze.com\/blog\/?p=1524\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cAndroid\u4e2d\u901a\u8fc7xml\u8d44\u6e90\u6587\u4ef6\u5b9a\u4e49\u6570\u7ec4\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[101,22],"_links":{"self":[{"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1524"}],"collection":[{"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1524"}],"version-history":[{"count":1,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1524\/revisions"}],"predecessor-version":[{"id":1525,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1524\/revisions\/1525"}],"wp:attachment":[{"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1524"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1524"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1524"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}