Skip to content

Instantly share code, notes, and snippets.

@figonzal1
Last active January 5, 2023 22:25
Show Gist options
  • Save figonzal1/70f465caed3ae7f7dd41bae4673d7cc1 to your computer and use it in GitHub Desktop.
Save figonzal1/70f465caed3ae7f7dd41bae4673d7cc1 to your computer and use it in GitHub Desktop.
val menuHost: MenuHost = requireActivity()
menuHost.addMenuProvider(object : MenuProvider {
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
menuInflater.inflate(R.menu.myMenu, menu)
}
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
when (menuItem.itemId) {
R.id.myItem -> {}
}
return true
}
}, viewLifecycleOwner, Lifecycle.State.RESUMED)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment