This question already has an answer here:
这个问题在这里已有答案:
- get list of the strings present in strings.xml file in Android 5 answers
获取Android 5答案中strings.xml文件中存在的字符串列表
I would like to get all values that are stored in the strings.xml file and store them in an array list that holds just strings. What would be the easiest way to achieve this??
我想获取存储在strings.xml文件中的所有值,并将它们存储在只包含字符串的数组列表中。实现这一目标最简单的方法是什么?
1 个解决方案
#1
0
You can do that with this one-liner:
你可以用这个单线程做到这一点:
ArrayList<String> list = new ArrayList(Arrays.asList(getResources().getStringArray(R.array.strings)));//where R.array.strings is a reference to your resource
#1
0
You can do that with this one-liner:
你可以用这个单线程做到这一点:
ArrayList<String> list = new ArrayList(Arrays.asList(getResources().getStringArray(R.array.strings)));//where R.array.strings is a reference to your resource