07-20-2023, 04:19 PM
In Java, instantiate an interface object is as easy as `new Interface()`... and override all the required functions as below, on `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
});
}
However, in Kotlin when we type
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 complaints unresolved References 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
});
}
However, in Kotlin when we type
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 complaints unresolved References AnimationListener.