Like basically everything with Kotlin Android Development, I am having trouble finding an example of how to utilize the MenuItem.SetOnActionExpandListener()
in Kotlin.
My menuItem
is a search action, and I need to trigger a function whenever the user closes the search. However, when searching how to do all of this, the only examples I find are in Java with zero information about how to do it in Kotlin...
I am attempting to use this solution, but I can't seem to figure out how to do this with Kotlin...
How do I convert that solution into Kotlin syntax?
Here's one way:
menuItem.setOnActionExpandListener(object : MenuItem.OnActionExpandListener {
override fun onMenuItemActionExpand(item: MenuItem?): Boolean {
// TODO: do something...
return true
}
override fun onMenuItemActionCollapse(item: MenuItem?): Boolean {
// TODO: do something...
return true
}
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With