0

I am trying to set a part of the label of an Activity with a string resource from strings.xml file.

I have declared my String as follows:

<string name="companyName">Company</string>

And on my Manifest.xml file I have the label attribute as follows:

<activity
     android:name="com.example.user.company.MainActivity"
     android:label="Login on @string/companyName"
     ...>
</activity>

But it shows the String as it is, I mean, Login on @string/companyName instead of Login on Company.

I know that I can set an extra string resource that contains the text Login on Company and directly set that string resource to the label of my Activity but I would not want to create that extra String if possible.

How can I set it as a part of a String?

EDIT: I also know that I can change the title programatically as @PriyankaChauhan suggested:

this.setTitle("Login on " + getResources().getString(R.string.companyName));

but I prefer not to mix logic and presentation. This is the reason why I am looking for a XML solution.

Thanks in advance!

Francisco Romero
  • 12,787
  • 22
  • 92
  • 167

0 Answers0