我一直在使用findViewById
,然后使用ButterKnife绑定视图。最近,我碰到了这篇文章:https : //proandroiddev.com/new-in-android-viewbindings-the-difference-from-databinding-library-bef5945baf5e,但不确定如何使用它。
我尝试这样做,但在Android Studio 3.4.2中似乎不起作用
val binding = MainActivityBinding.inflate(layoutInflater)
setContentView(binding.root)
然后使用这些值作为示例:
binding.button....
binding.textView....
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句