Kotlin synthetic in Adapter or ViewHolder

前端 未结 7 642
孤独总比滥情好
孤独总比滥情好 2020-12-13 05:36

I am new in kotlin. I have found and tried to use synthetic method instead of annoying method findViewById in my Activity class, but I have found \

相关标签:
7条回答
  • 2020-12-13 06:10

    Try

    class CustomViewModel(val baseView: View) {
        val firstName = baseView.firstName
        val lastName = baseView.lastName
    }
    

    View object exposes the views ref:https://discuss.kotlinlang.org/t/unable-to-use-kotlin-android-extension-in-adapter-class/2890

    0 讨论(0)
提交回复
热议问题