在res/values/下新建menu_names.xml
代码如下:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="menu_names">
<item>xx1</item>
<item>xx2</item>
<item>xx3</item>
</string-array>
</resources>
onCreate(Bundle savedInstanceState) 方法中:
String[] stringArray = getResources().getStringArray(R.array.menu_names);
menuList = new ArrayList<String>();
for (String str : stringArray) {
menuList.add(str);
}
获取xml里的值