res/values/arrays.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <string-array name="sports"> <item>足球</item> <item>篮球</item> <item>太极</item> <item>乒乓球</item> </string-array> <string-array name="subject"> <item>语文</item> <item>数学</item> <item>英语</item> <item>安卓</item> </string-array> </resources>
A:在代码中使用
String[] sports = getResources().getStringArray(R.array.sports); String[] subject = getResources().getStringArray(R.array.subject); for(String s: sports) { System.out.println(s.toString()); } for(String s:subject) { System.out.println(s.toString()); }原文链接:https://www.f2er.com/xml/298033.html