-1

in resourse values I have one xml file, here i have facebook_app_id value:

 <string name="facebook_app_id">1769573166657682</string>

I need to reuse this values in another tag

<string name="fb_login_protocol_scheme">fb1769573166657682</string>

Can I use value of facebook_app_id like this?

<string name="fb_login_protocol_scheme">fb@string/facebook_app_id</string>
Alex
  • 8,908
  • 28
  • 103
  • 157

2 Answers2

0

What you are trying to do is concatenate a String and a String resource. I am afraid this is not possible in android through xml files.

What you can do is declare the two string and have a utility method that concatenate them.

<string name="facebook_app_id">1769573166657682</string>

<string name="fb_login_protocol_scheme">fb$1s</string>

and then just use String.format to replace the first string parameter with the app id.

dzsonni
  • 194
  • 1
  • 13
0

I am afraid that is not possible in strings.xml.

What you can do is create the final string programmatically. Something like.

    String outStr = getString(R.string.fb) + 
  " " + getString(R.string.facebook_app_id);
Magesh Pandian
  • 8,789
  • 12
  • 45
  • 60