https://kotlinlang.org logo
#android
Title
# android
a

Alin B.

07/12/2018, 8:24 PM
I am trying to do data binding in android and I have a question: if I have a
fragment
with
recyclerview
so basically: 1. in
fragment
get the
ViewModel
and call `viewModel.data().observer(...){adapter.submitList(result)} 2. in
ViewModel
I have
data()
as
repository.getData()
returning
LiveData
3. inside the adapter do `bind`within
onBindViewHolder
to the item from
data
at current position. 4. in the xml for list item add the binding as
<variable name="item" type="package.data"/>
Is this right or wrong?