Android Kotlin-如何通过改造类和活动之间的接口传递数据

Android Kotlin-如何通过改造类和活动之间的接口传递数据,android,kotlin,interface,retrofit2,Android,Kotlin,Interface,Retrofit2,我正在实施一个对GooglePlacesAPI进行改造的项目。我使用一个接口(orPredictionRespossListener)将调用返回的数据传递给我的主活动。然而,由于我是kotlin的新手,我在以正确的方式初始化接口时遇到了一些困难。下面是我如何在改造类中实现接口: class RetrofitCaller(onPredictionResponseListenerInterface: `OnPredictionResponseListener`) { //declare inter

我正在实施一个对GooglePlacesAPI进行改造的项目。我使用一个接口(orPredictionRespossListener)将调用返回的数据传递给我的主活动。然而,由于我是kotlin的新手,我在以正确的方式初始化接口时遇到了一些困难。下面是我如何在改造类中实现接口:

class RetrofitCaller(onPredictionResponseListenerInterface: `OnPredictionResponseListener`) {

//declare interface object
private var onPredictionResponseListener : OnPredictionResponseListener
    get() {
        TODO()
    }

init {
    this.onPredictionResponseListener = onPredictionResponseListenerInterface
}
关于改装数据响应:

onPredictionResponseListener.onCallResponse(actualList)
最后,在我的主要活动中,我实现了接口,并重写了它的onCallResponse方法,但是当我初始化它以便将其作为参数传递给改造构造函数时,我得到了错误。我应该如何在我的活动中初始化它

val onPredictionResponseListener : OnPredictionResponseListener
retrofitCaller = RetrofitCaller(onPredictionResponseListener)