title: Android two-way data binding working one way only
body: <p>I'm having this problem for a while, hope someone can help me</p>
  
  <p>I'm trying to implement two-way data binding for the first time, but I'm facing a weird problem.</p>
  
  <p>The problem here is that every time that I set a value of a live data from my view model, the UI changes, but when I change the edit text value on the UI, it does not reflect on the view model live data value.
  Seems like the <em>two-way</em> data binding is working <em>one-way</em> only, when the value is set from the view model</p>
  
  <p>I have my view model, something like this:</p>
  
  <pre><code>class CreateAssignmentViewModel(): ViewModel() {
      val assignment = MutableLiveData&lt;String&gt;()
  }
  </code></pre>
  
  <p>then my activity:</p>
  
  <pre><code>class CreateAssignmentActivity: AppCompatActivity() {
      private val createViewModel: CreateAssignmentViewModel by viewModel()
      private lateinit var viewBinding: ActivityCreateAssignmentBinding
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
  
          viewBinding = DataBindingUtil.setContentView(this, R.layout.activity_create_assignment)
          viewBinding.lifecycleOwner = this
          viewBinding.createViewModel = createViewModel
      }
  }
  </code></pre>
  
  <p>and then on my activity xml:</p>
  
  <pre><code>&lt;layout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"&gt;
  
      &lt;data&gt;
          &lt;import type="android.view.View" /&gt;
  
          &lt;variable
              name="createViewModel"
              type="com.marcelo.tasks.assignments.create.CreateAssignmentViewModel" /&gt;
      &lt;/data&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:orientation="vertical"
          tools:context=".assignments.create.CreateAssignmentActivity"&gt;
  
          &lt;EditText
              style="@style/Base.EditText"
              android:text="@{createViewModel.assignment}" /&gt;
  
      &lt;/LinearLayout&gt;
  &lt;/layout&gt;
  
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/E7tJv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E7tJv.png" alt="image showing that its not working"></a></p>