Android 如何将ArrayList元素(项)放入TextView?

Android 如何将ArrayList元素(项)放入TextView?,android,arrays,xml,string,textview,Android,Arrays,Xml,String,Textview,我的strings.xml中有一个ArrayList。我想从中选择元素并将其放入.setText()中。如何执行此操作?是否应在arrays.xml中声明ArrayList?如果是,请使用Context.getResource().getStringArray()选择元素示例:保存在res/values/strings.xml中的xml文件: <?xml version="1.0" encoding="utf-8"?> <resources> <string

我的strings.xml中有一个ArrayList。我想从中选择元素并将其放入.setText()中。如何执行此操作?

是否应在arrays.xml中声明ArrayList?如果是,请使用
Context.getResource().getStringArray()
选择元素示例:保存在res/values/strings.xml中的xml文件:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="planets_array">
        <item>Mercury</item>
        <item>Venus</item>
        <item>Earth</item>
        <item>Mars</item>
    </string-array>
</resources>
将值指定给textView:

    TextView textView = (TextView) findViewById(R.id.textView1); 
    textView.setText(planets[1]);  //Venus
更多信息请访问:


你需要让我们知道你到目前为止尝试了什么,粘贴一些你尝试过的代码…我有在TextView中设置字符串的代码,我有一个算法,可以从数组中随机选择一个元素。我知道如何在Java中实现这一点,但我不知道如何从XML中的ArrayList获取它。
    TextView textView = (TextView) findViewById(R.id.textView1); 
    textView.setText(planets[1]);  //Venus