Android Studio - Kotlin - open fragment from optionsmenu
Hello community I am new at kotlin and want to ask, if someone could help me to write some functions which allow me to open a fragment when the item in the optionsmenu is clicked. I can't get any info about it online and I think, I am a too beginner-minded person to go for it alone. I hava a optionsmenu.xml file which acts like the main_activity. In there, there are 5 items with the ids optionsmenuitem1-5 When I click in the optionsmenu on "Backups" it should open the BackupFragment. Does anyone have an idea how I could handle this, or what I do wrong? Basically I realised, that I don't have that much understanding to solve it. MainActivity.kt: // open BackupFragment from optionsmenu override fun onClick(view: View?) { when(item?.optm_backupitem){ R.id.backupfragment->{ return true } Thank you very much for trying to help me. Kind regards Pascal