Created
November 2, 2021 21:24
-
-
Save jaozinfs/924ce0b7ea2e7bfaeb34597fb369b4c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExampleActivity : ComponentActivity(R.layout.activity_example) { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
// Add menu items without overriding methods in the Activity | |
addMenuProvider(object : MenuProvider { | |
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) { | |
// Add menu items here | |
menuInflater.inflate(R.menu.example_menu, menu) | |
} | |
override fun onMenuItemSelected(menuItem: MenuItem): Boolean { | |
// Handle the menu selection | |
return true | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment