我开发一个Android应用程序。我需要将一个字符串数组转换成一个ArrayList。我已经在这读了,一切都在您添加值到Java文件中的数组的情况下。我宣布了字符串数组中的strings.xml文件。我的字符串数组是在这里:
I'm developing an Android app. I need to convert a string array into an ArrayList. I've read up on this, and all have cases where you add the values to the array in the java file. I have declared the string-array in the strings.xml file. My string-array is here:
<string-array name="Lines">
<item>Red Line</item>
<item>Blue Line</item>
<item>Orange Line</item>
<item>Green Line</item>
<item>Brown Line</item>
<item>Purple Line</item>
<item>Pink Line</item>
<item>Yellow Line</item>
</string-array>
我需要线转换成ArrayList中。如果我用这个
I need to convert Lines into ArrayList. If I use this
List<String> Lines = new ArrayList<String>();
宣布ArrayList中,如何可以找到ID的数组列表,并存储为线?
to declare the ArrayList, how can find the array list by ID, and store that as Lines?
试试这个;
List<String> Lines = Arrays.asList(getResources().getStringArray(R.array.Lines));