android: data binding error: cannot find symbol class

后端 未结 26 3096
生来不讨喜
生来不讨喜 2020-12-14 05:49

I am getting started for using DataBinding feature. I am facing problem with it.

Error:(21, 9) error: cannot find symbol class ContactL

26条回答
  •  北荒
    北荒 (楼主)
    2020-12-14 05:54

    In my case I had the same issue but the reason was different. My onClick function was declared private in the activity class, so be sure that, if you are using a handler function inside the layout, the function must not be private.

    // this will not be visible in the binded layout because it's private!
    private fun mainButtonClick(view: View) {
        if (viewModel.isRecording.value == true) {
            stopRecordingAndPlaying()
        } else {
            startRecordingAndPlaying()
        }
    }
    

提交回复
热议问题