【发布时间】:2023-03-08 23:24:01
【问题描述】:
在 Java 中,实例化接口对象就像 new Interface()... 一样简单,并在 AnimationListener 上覆盖所有必需的函数,如下所示
private void doingSomething(Context context) {
Animation animation = AnimationUtils.loadAnimation(context, android.R.anim.fade_in);
animation.setAnimationListener(new Animation.AnimationListener() {
// All the other override functions
});
}
然而,当我们在 Kotlin 中键入时
private fun doingSomething(context: Context) {
val animation = AnimationUtils.loadAnimation(context, android.R.anim.fade_in)
animation.setAnimationListener(Animation.AnimationListener(){
// All the other override functions
})
}
It error 投诉 unresolved References AnimationListener.
【问题讨论】: