0

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.

2
  • As you just want to label broadcastreceiver that wil only be used once. So Just write the whole string there Commented Apr 20, 2013 at 3:21
  • It is for labeling about 3 receivers which need different separators for different api levels and different translations for action. I was hoping to define the terms once and the separators once instead of repeating them for every variation. Commented Apr 20, 2013 at 3:22

1 Answer 1

1

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) + " --";
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, but via code isn't really an option. This is for labeling broadcast receivers.
But multiple referencing is not possible . Tell me where you want to implement this?

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.