0

Android xml string item how to connect two item enter image description here

3
  • This does not work in android. You would have to load both strings at runtime and concatenate them. Commented Dec 15, 2016 at 1:43
  • stackoverflow.com/questions/3656371/… Commented Dec 15, 2016 at 2:01
  • the "c" value is used in AndroidMinifest.xml Commented Dec 15, 2016 at 2:44

2 Answers 2

1

If you have these strings:

<string name="a">Hello</string>
<string name="b">World</string>

Then in your Activity you would do this:

String a = getString(R.string.a);
String b = getString(R.string.b);
String c = a + " " + b;

Alternatively, you can add a third string and retrieve it this way:

<string name="c">%s %s</string>

String c = getString(R.string.c, a, b);
Sign up to request clarification or add additional context in comments.

Comments

0

I think we can use string-array

<string-array name="c">
        <item> @string/a</item>
        <item> " " </item>
        <item> @string/b</item>
</string-array>

an in code

String c = Arrays.toString(getResources().getStringArray(R.array.c));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.