setText() 来自 xml 的多个字符串

setText() multiple strings from xml

也许是一个简单的问题 - 我需要帮助从我的 strings.xml.

中设置多个字符串
 mytext.setText(resources.getString(R.string.history_text1+R.string.history_text2));

所以我的意思是我需要通过一个 setText 将 2 个不同的文本作为一个。

但是使用这种语法我有一个错误:android.content.res.Resources$NotFoundException: String resource ID #0xfe1e0079

试试这个:

 mytext.setText(resources.getString(R.string.history_text1) + resources.getString(R.string.history_text2))

值:
R.string.history_text1R.string.history_text2
是引用资源中实际字符串的整数。
通过添加它们,您会得到另一个没有引用任何内容的整数,因此您会得到:

Resources$NotFoundException

如果您想连接 2 个字符串值:

String value = resources.getString(R.string.history_text1) + resources.getString(R.string.history_text2)
mytext.setText(value);