一、使用
1、Enable data binding
buildFeatures {
dataBinding true
}
2、改变xml文件
<layout>
<LinearLayout ... >
...
</LinearLayout>
</layout>
3、在Activity中使用
(1)属性定义
private lateinit var binding: ActivityMainBinding
(2)onCreate()赋值
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
replace the setContentView()
(3)replace findViewById
Replace this code: findViewById(R.id.done_button) with: binding.doneButton
binding.apply {
nicknameText.text = nicknameEdit.text.toString()
nicknameEdit.visibility = View.GONE
doneBu