Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何连接到xml文件?_Java_Android_Xml - Fatal编程技术网

Java 如何连接到xml文件?

Java 如何连接到xml文件?,java,android,xml,Java,Android,Xml,我在java代码中有一个按钮: Button next = (Button) findViewByID(R.id.Button1); 我希望每次单击按钮时,我都能更新此表单中的string.xml: <string-array name="steps"> <item >step1</item> <item >step2</item> <item >step3</item> </s

我在java代码中有一个按钮:

Button next = (Button) findViewByID(R.id.Button1);
我希望每次单击按钮时,我都能更新此表单中的string.xml:

<string-array name="steps">
    <item >step1</item>
    <item >step2</item>
    <item >step3</item>
 </string-array>

我不知道从哪里开始。

您所要做的就是使用数组和所需索引设置textview的文本 例如,您希望在oncreate中将名为t1的textview设置为索引1

 t1.setText(getResources().getStringArray(R.array.steps)[1]);

检查我下面的答案,让我知道它是否对你有帮助;您无法连接到文件。你打开它们。只要人们明白你想说的是什么,这才是重要的,不管是错误、语法还是其他什么,所以这不是你想要的。我想这会对你有帮助。非常感谢。