title: Data binding to objects of a complex type in an MutableList
body: <p>I have an activity that should display a non-fixed amount of fragments. Each fragment will receive an element of a MutableList of <code>Customer</code> and it needs to have its components bound to a property in this <code>Customer</code> class.</p>
  
  <p>I've created the class like this:</p>
  
  <pre><code>class Customer constructor(
      val name: LiveData&lt;String&gt;
      val email: LiveData&lt;String&gt;
  )
  </code></pre>
  
  <p>In my <code>ViewModel</code> I've created the <code>MutableList</code> of <code>Customer</code>:</p>
  
  <pre><code>class CustomerViewModel: ViewModel() {
  
      val customers: MutableList&lt;Customer&gt; = mutableListOf()
  }
  </code></pre>
  
  <p>Then I dynamically create the Fragments:</p>
  
  <pre><code>for (i in 0..customerCount) {
    val fragment = FragmentCustomer.newInstance(viewModel.customers.get(i))
    supportFragmentManager.beginTransaction()
      .add(R.id.fragmentContainer, fragment, "FragmentCustomer_$i")
      .commit()
  }
  </code></pre>
  
  <p>The customer instance is stored in a variable in the Fragment and then I do the <code>DataBindingUtil.inflate</code>:</p>
  
  <pre><code>var binding: FragmentCustomerBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_customer, container, false)
  var view = binding.root
  
  binding.model = palavra
  return view
  </code></pre>
  
  <p>And in the Fragment's layout:</p>
  
  <p>
      
  
  </p>
  
  <pre><code>&lt;EditText
      android:id="@+id/nameTextView"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      android:text="@{model.name}"
      android:onTextChanged="@={model.name}" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>This is causing <code>****/ data binding error ****msg:The expression modelName.getValue() cannot be inverted: There is no inverse for method getValue, you must add an @InverseMethod annotation to the method to indicate which method should be used when using it in two-way binding expressions</code>.</p>
  
  <p>How can I fix this? And a "bonus" question, do I still have to store view content using savedState on events like <code>onDestroy</code> or ViewModel will handle that for me?</p>