Is it possible to reference one string in strings.xml inside another string that contains other text?
Something that is allowed in XML, and would achieve this effect:
<string name="string_one">My string</string>
<string name="string_two">Here it is: android:id="@string/string_one"</string>
A string resource provides text strings for your application with optional text styling and formatting. There are three types of resources that can provide your application with strings: String. XML resource that provides a single string.
To include special characters inside XML files you must use the numeric character reference instead of that character. The numeric character reference must be UTF-8 because the supported encoding for XML files is defined in the prolog as encoding="UTF-8" and should not be changed.
The XML resource files containing localized strings are placed in subfolders of the project's res folder. Android uses a special folder-naming scheme to automatically choose the correct localized resources—for example, the folder values-fr would contain a strings.
I don't think it's possible. What I usually do is the following:
<string name="string_one">My string</string>
<string name="string_two">Here it is: %s" </string>
and in the java code:
String.format(getString(R.string.string_two), getString(R.string.string_one));
I do this kind of thing for parametrize msgs like: "You have %d new mails".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With