Can one combine android resource strings into new strings?

android

Solution

No, it's not possible. You can just use `<string name="bar">This is my %s</string>` and then use `String.format()` in your app to fill in the variable with for example

getResources().getString(R.string.foo);

Problem

Android allows to create aliases of resource strings like: ``` <resources> <string name="foo">somestring</string> <string name="bar">@string/foo</string> </resources> ``` by which the resource "bar" becomes an alias for the resource named "foo". What I would for my app is a possibility to combine an existing resource prefix with different suffixes, i.e. to extend it like: ``` <resources> <string name="foo">foo</string> <string name="bar">@string/foo+bar</string> <string name="else">@string/foo+else</string> </resources> ``` where the resource "bar" would yield the string "foobar". Its clear that '+' doesn't work here but is there some other option to achieve such a string concatenation, so that one could define a bunch of string resources that have a common prefix? I realize of course that I could do such resource string concatenation at runtime but defining them statically in the resources would seem so much more elegant and simpler. Michael

Original source