title: How to pass editText value to viewModel and Livedata (Kotlin)
body: <p>I'm studying Android + Kotlin and make a simple example to understand LiveData + ViewModel. It's very simple: I have one root activity and two fragments. FragmentOne has two EditTexts. That values are summed and I need to pass the result to a ViewModel. Then I use observe in both root activity and FragmentTwo to see the changed data.</p>
  
  <p><strong>FragmentOne</strong></p>
  
  <pre><code>class FragmentOne: Fragment() {
     private val model by lazy { ViewModelProviders.of(activity).get(MyViewModel::class.java) }
     var resultSum:Int = 0
  
     override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
       val view = inflater?.inflate(R.layout.fragment_one,container,false)
       val btn = view?.findViewById&lt;Button&gt;(R.id.sendToModel)
       btn?.setOnClickListener({
           val field1 = n1.text.toString().toInt()
           val field2 = n2.text.toString().toInt()
           resultSum = field1 + field2
           model.update()
       })
       return view
    }
  }
  </code></pre>
  
  <p><strong>viewModel</strong></p>
  
  <pre><code>class MyViewModel: ViewModel() {
     private val fragment by lazy {FragmentOne()}
     private var _result = MutableLiveData&lt;Int&gt;().apply { value = 0 }
     val result: LiveData&lt;Int&gt;
        get() = _result
  
     fun update(){
         _result.value = fragment.resultSum
     }
  }
  </code></pre>
  
  <p><strong>Observer root activity</strong></p>
  
  <pre><code>private val resultModel by lazy {ViewModelProviders.of(this).get(MyViewModel::class.java)}
  resultModel.result.observe(this, Observer { result -&gt; resultTxt.text = result.toString()})
  </code></pre>
  
  <p><strong>Observer FragmentTwo</strong></p>
  
  <pre><code>private val resultModel by lazy {ViewModelProviders.of(activity).get(MyViewModel::class.java)}
  resultModel.result.observe(this, Observer { result -&gt; resultTxt.text = result.toString()})
  </code></pre>
  
  <p>I checked <code>var resultSum</code> (Log) and It hold Int value from sum. The observer is working too (if I instantiate <code>result.value</code> inside ViewModel, the value is observable to activity and fragment)</p>
  
  <p>I appreciate any help.</p>