op_man
op_man

Reputation: 35

Formatting string from resource in XML

I have a fragment with ViewModel and a string resource like this

<string name="money_format">Money: %1$d</string>

In ViewModel I have MutableLivaData money. How I can set in fragment's XMLfile a text property to money_format with parameter Money from viewModel

Upvotes: 2

Views: 58

Answers (1)

iknow
iknow

Reputation: 9852

It'll look like this

android:text="@{@string/money_format(viewModel.money)}"

Upvotes: 2

Related Questions