Using LiveData with Data Binding

后端 未结 4 534
情书的邮戳
情书的邮戳 2020-12-28 14:28

With the stabilization of Android Architecture Components I started updating all my basic ViewModels to the new implementation ofViewModel. In my understanding,

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-28 15:11

    For androidx will be:

    androidx.lifecycle.MutableLiveData

    
        
            
        
    
        ...
    
        
    
        ...
    
    
    

    And for Kotlin:

      val myStr = MutableLiveData()
    
    ...
    
     binding.apply {
                setLifecycleOwner(this)
                this.myString = myStr
            }
    

    Good luck! :)

提交回复
热议问题