Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.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_String - Fatal编程技术网

Java/XML:在另一个字符串中使用一个字符串

Java/XML:在另一个字符串中使用一个字符串,java,android,xml,string,Java,Android,Xml,String,可以在另一根绳子上使用刺吗 我想要的是: <string name="homepage">http://www.examplepage.com</string> <string name="desc">Go to my Website: "string:"homepage"</string> http://www.examplepage.com 转到我的网站:“字符串:“主页” 因此,如果我有更多的字符串显示我的主页,如果我不想更改每个字符串,

可以在另一根绳子上使用刺吗

我想要的是:

<string name="homepage">http://www.examplepage.com</string>
<string name="desc">Go to my Website: "string:"homepage"</string>
http://www.examplepage.com
转到我的网站:“字符串:“主页”

因此,如果我有更多的字符串显示我的主页,如果我不想更改每个字符串,只更改“主页”字符串,我该如何处理

<string name="homepage">http://www.examplepage.com</string>
<string name="desc">Go to my Website: %s</string>

你在哪里使用这些值?我在android项目的XML文件中使用了这些值。我想在应用程序中多次显示我的主页。但是如果我想更改URL,我不想更改每个字符串。只要一个。好吧,你不能仅使用XML直接执行此操作。为什么不在Java中使用字符串,以便修改它们。如果你想访问在应用程序中的任何地方都可以使用SharedReferences。谢谢。效果很好:)以下是有关格式设置的更多信息:
Resources res = getResources();
String.format(res.getString(R.string.desc), res.getString(R.string.homepage));