Asked
            
        
        
            Active
            
        
            Viewed 71 times
        
    0
            
            
         
    
    
        Linh
        
- 57,942
- 23
- 262
- 279
 
    
    
        fater zamoli
        
- 11
- 3
- 
                    This does not work in android. You would have to load both strings at runtime and concatenate them. – Karakuri Dec 15 '16 at 01:43
- 
                    http://stackoverflow.com/questions/3656371/dynamic-string-using-string-xml/24903097#24903097 – Randyka Yudhistira Dec 15 '16 at 02:01
- 
                    the "c" value is used in AndroidMinifest.xml – fater zamoli Dec 15 '16 at 02:44
2 Answers
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);
 
    
    
        Karakuri
        
- 38,365
- 12
- 84
- 104
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));
 
    
    
        Linh
        
- 57,942
- 23
- 262
- 279
