In Java implementiert, instanziiert ein Interface-Objekt als new Interface()
so einfach ist ... und außer Kraft setzen alle erforderlichen Funktionen, wie unten, auf AnimationListener
Wie eine anonyme Klasse instanziiert, die eine Schnittstelle in Kotlin
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
});
}
jedoch in Kotlin, wenn wir schreiben
private fun doingSomething(context: Context) {
val animation = AnimationUtils.loadAnimation(context, android.R.anim.fade_in)
animation.setAnimationListener(Animation.AnimationListener(){
// All the other override functions
})
}
Es Fehler Beschwerden ungelöst Referenzen AnimationListener.
Mögliches Duplikat von [Wie eine Instanz der anonymen Schnittstelle in Kotlin erstellen?] (Http://stackoverflow.com/questions/37672023/how-to-create-an-instance-of-anonymous-interface -in-kotlin) – miensol