fabiomsr / MoneyTextView

A simple Android TextView to display amounts of money in different formats.
509 stars 71 forks source link

Data binding not supported. #11

Open maxAman opened 6 years ago

maxAman commented 6 years ago

when I am trying to set , app:amount="@{data.totals.subTotal}" then the issue occurs. Please do something

dphans commented 4 years ago

I think this is not issue. You can custom binding adapter:

object MoneyTextViewBindingAdapter {

    @JvmStatic
    @BindingAdapter(value = ["moneyTextViewValue", "moneyTextViewSymbol"], requireAll = false)
    fun moneyTextViewValue(sender: MoneyTextView, value: Float?, symbol: String?) {
        sender.setAmount(value ?: 0.0f, symbol ?: "")
    }
}

And in layout xml file, use your custom binding adapter instead of library attribute amount:

<org.fabiomsr.moneytextview.MoneyTextView
    moneyTextViewSymbol="@{ presenter.defaultCurrency.symbol_native }"
    moneyTextViewValue="@{ safeUnbox(viewModel.thisMonthExpensed) }"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />