-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>
1
  • Is there any reason to use this way ? Commented Oct 24, 2016 at 12:42

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.