How to create an instance of anonymous interface in Kotlin?

前端 未结 4 1161
北海茫月
北海茫月 2020-12-02 09:49

I have a third party Java library which an object with interface like this:

public interface Handler {
  void call(C context) throws Exception;
}
         


        
4条回答
  •  再見小時候
    2020-12-02 10:10

         val obj = object : MyInterface {
             override fun function1(arg:Int) { ... }
    
             override fun function12(arg:Int,arg:Int) { ... }
         }
    

提交回复
热议问题