agoebel
agoebel

Reputation: 401

Referring to multiple string resources

Is there a way to refer to multiple resources inside another? It's easier to just show some sample code.

<resources>
   <string name="app_name">AppName</string>
   <string name="sep">--</string>
   <string name="action">MyAction</string>

   <string name="action_title">@string/app_name @string/sep @string/action</string>
</resources>

So that @string/action_title should be AppName -- MyAction

However, when I use this it seems that R.java just chokes and doesn't get built. Am I missing something or is this just impossible?

Edit I am using this to label BroadcastReceivers in my AndroidManifest.xml so doing it in code doesn't seem to be an option.

Upvotes: 0

Views: 74

Answers (1)

stinepike
stinepike

Reputation: 54672

It is possible as long as you are using a single reference like

   <string name="app_name">AppName</string>
   <string name="sep">@string/AppName</string>

But you can not do multiple reference like you wanted nor like following

   <string name="app_name">AppName</string>
   <string name="sep">@string/AppName  --</string>

You can do that from code

   String s = getString(R.string.app_name) + " --";

Upvotes: 1

Related Questions