I go through this How to concatenate multiple strings in android XML? and in the end there are comments that
For clarity, Its works:
&
Yes, you can do so without having to add any Java/Kotlin code, just XML, by using this library: https://github.com/LikeTheSalad/android-string-reference which does that at buildtime.
For your case, you'd have to set up your strings like this:
<string name="aaa">Some text</string>
<string name="template_bbb">bbb ${aaa}</string>
And then the library will create the following at buildtime:
<string name="bbb">bbb Some text</string>
Disclaimer: I'm the author of this library.
No, but is posible in xslt file with concat function:
<html>
<body>
<ul>
<xsl:for-each select="stock">
<xsl:if test="starts-with(@symbol, 'C')">
<li>
<xsl:value-of select="concat(@symbol,' - ', name)" />
</li>
</xsl:if>
</xsl:for-each>
</ul>
</body>
</html>
http://www.java2s.com/Tutorial/XML/0100__XSLT-stylesheet/concatfunction.htm
Kotlin version:
strings in the xml:
<string name="school_girl">Gogo Yubari</string>
<string name="assistant">Sofie Fatale</string>
<string name="boss">O-Ren Ishii</string>
<string name="list">%s, %s, %s</string>
and then in the code:
val killBillV1 = getString(R.string.list).format(
Locale.US,
getString(R.string.school_girl),
getString(R.string.assistant),
getString(R.string.boss)
)
No, you can't concatenate strings in XML but you can define XML resources.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE resources [
<!ENTITY appname "MyAppName">
<!ENTITY author "MrGreen">
]>
<resources>
<string name="app_name">&appname;</string>
<string name="description">The &appname; app was created by &author;</string>
</resources>
The original answer was posted here.