4

This is what I want to do, in standard way.

<string name="foo">foo</string>
<string name="foo_bar">foo bar</string>

Can I rewrite like below?

<string name="foo">foo</string>
<string name="foo_bar">@string/foo bar</string>

I know this is not in schema, however, it is OK like below,

<string name="foo">foo</string>
<string name="altfoo">@string/foo</string>

Why!?

Nkzn
  • 41
  • 9

1 Answers1

2

This

<string name="foo">foo</string>
<string name="foo_bar">@string/foo bar</string>

wrong coz there is no resource with the name foo bar

The above would be right if you had

<string name="foo bar">foo and bar</string>
<string name="foo_bar">@string/foo bar</string>

This

<string name="foo">foo</string>
<string name="altfoo">@string/foo</string>

is right coz there is a resource with name foo and you are referencing the same

You may want to check

Concatenate Strings in the strings.xml file for Android

Community
  • 1
  • 1
Raghunandan
  • 132,755
  • 26
  • 225
  • 256