Is there a way to pass a function reference between activities?

后端 未结 5 474
后悔当初
后悔当初 2020-12-10 12:05

is there a way of bundling function references in Kotlin and Android so that the functions can be called from other fragments? For instance, my fragment factory method look

5条回答
  •  春和景丽
    2020-12-10 12:17

    If it is not possible to put a function literal into a Bundle, however, you can pass the function to the Fragment through a setter like function in the Fragment.

    fun setTryAgainFunction(tryAgainFunction: () -> Unit) {
    
    }
    

提交回复
热议问题