Reputation: 2802
I would like to assign a string resource and some additional text to a textview. Is there a way to do this, without adding a second textview?
Something like this:
android:text="@string/DESCRIPTION"+": "
Upvotes: 0
Views: 1109
Reputation: 30934
You can do similar with Context.getString(id,args...)
. As an Activity
inherits from Context
you can just directly use it in code.
values/strings.xml:
<string name="DESCRIPTION">Hello %s</string>
Activity:
String result = getString(R.string.DESCRIPTION,"world");
Upvotes: 1
Reputation: 14472
As far as I know, this can't be done. You will have to do it in code:
textViewTitle.setText(getResources().getString(R.string.DESCRIPTION) + ": ");
Upvotes: 0
Reputation: 43088
Nope, text attribute doesn't support this. But you can use formatting api for your goals. Read here.
Upvotes: 0