android中定义和使用数组

来源:互联网 发布:大数据 量化投资 编辑:程序博客网 时间:2024/04/29 13:41

<resources>
    <!-- Used in View/Spinner1.java -->
    <string-array name="colors">
        <item>red</item>
        <item>orange</item>
        <item>yellow</item>
        <item>green</item>
        <item>blue</item>
        <item>violet</item>
    </string-array>
</resources>


//java code
Resources res = this.getResources();


String[] arr = res.getStringArray(R.array.colors);
for(int i=0; i<arr.length-1; i++) {
        Log.i("TEST", arr[i]);

}

原创粉丝点击