I have a function:
fun test(){
Timber.d("Button Clicked")
}
And I'm trying to pass this function to a fragment. Here is that field inside my fragment.
class MyFragment(val layout: Int) : Fragment() {
var clickEvent1: (() -> Unit)? = null
}
And this is how I'm setting this field before beginning fragment transaction.
fragment.clickEvent1 = {test()}
My goal is to run this function on my button click inside my fragment.
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
dialog_option_1.setOnClickListener { clickEvent1 }
}
There's an issue with the way I'm doing this because the "test" function does not run. Can someone point me in the right direction? Thanks