I am displaying a Error message in a Toast with strings.xml
.
Like this
mErrorMsgId=R.string.username_or_password_incorrectfull;
But now i need to concatenate the message with R.string.add_selfhosted_blog
to avoid translation inconsistencies.
Read some similar questions but can't figure it out.
EDIT:
I want to concatenate nux_add_selfhosted_blog after the word tap in the username_or_password_incorrectfull string ...
<string name="username_or_password_incorrectfull">The username or password you entered is incorrect
\- If you\'re a self hosted user, don\'t forget to tap **Add Self Hosted Site** and fill the URL field</string>
<string name="nux_add_selfhosted_blog">Add self-hosted site</string>
How can i acheive this ??
You cannout concatenate R.string.username_or_password_incorrectfull
with R.string.add_selfhosted_blog
directly as they are not String
instances as such but rather the resource id to the actual String in the strings.xml
. You can get the 2 strings and then concatenate them normally.
Something like this:
String string1 = getResources().getString(R.string.username_or_password_incorrectfull);
String string2 = getResources().getString(R.string.add_selfhosted_blog);
String combined = string1 + string2;
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