Why equals always return false in layout xml (databinding)?

Viewed 30
1 Answers

I check your AccompanimentMenuFragment android:checked="@{viewModel.accompaniment.name.equals(@string/pickles)}"

Here viewModel.accompaniment.name has value "Pickled Veggies" and in string "pickles".

viewModel.setAccompaniment(@string/pickles)}" is setting value from your DataSource which has name "Pickled Veggies".

_accompaniment.value = menuItems[accompaniment] in this line menuItems[accompaniment] is getting value from DataSource which has

"pickles" to MenuItem( name = "Pickled Veggies", description = "Pickled cucumbers and carrots, made in house", price = 0.50, type = ItemType.ACCOMPANIMENT )

Hence you "Pickled Veggies" is getting compared with "pickles" which gives false result. Same issue is with other fragments

Related