+ 1

Error in options menu function - Kotlin - please help

What about that options menu function? Options menu error - kotlin - please help Dear community I am a kotlin-beginner and learning since 3 months. Right now, I am dealing with the options-menu onclick functions (or something like that) I've created an options menu and now I want to just implement an "on options menu item select" onclick listener which wil show these single fragments when the item in the options is clicked. I dont't know what to do with these functions. For what exactly do I need these functions? What should be in these functions? Please help, I am dealing with these errors since 3 weeks. Thank you all for every single piece of help. I got the starter-Code from the android developer-website. https://www.sololearn.com/post/942751/?ref=app https://code.sololearn.com/cML5Sn4Hi5z6/?ref=app

20th Feb 2021, 12:12 PM
Tech
7 Respostas
+ 2
it must be inside an activity (settings _screen) which is child of preference fragment So you could create This kind of code ```kt fun startoptionsmenufeedback(item : MenuItem){ startActivity(Intent(this, THE_ACTIVITY_WHERE_SETTING_SCREEN_IS_LOCATED::class.java)) } ```
22nd Feb 2021, 11:51 AM
Ananiya Jemberu
Ananiya Jemberu - avatar
+ 2
Tech have you create a function called `startoptionsmenuhelp()` if not this is the error And also the other error I got is instead of returning before(outside) if conditions `super.onOptionItemSelected(item)` You should return it inside if condition https://code.sololearn.com/cKLA7J9ZSJzL/?ref=app happy to help :)
20th Feb 2021, 4:34 PM
Ananiya Jemberu
Ananiya Jemberu - avatar
+ 2
"What exactly should be in these function" Tech Umm, let me guess what you are thinking ... I guess you where expecting `startoptionsmenu...` declared(created) by them selves in your project but No, they are not. You can just take your screenshot as reference it show you red coloured these function is not writtened (created) either in ide or your selve any where So where did you find the course it is difnetiley useful for taking the error, if you have the link give sorry if I made my languge hard
20th Feb 2021, 8:03 PM
Ananiya Jemberu
Ananiya Jemberu - avatar
+ 1
Yeah but actually I need to know what actually that do for example we could create a function like ``` fun startoptionsmenufeedback(item MenuItems){ Intent(this, ThatActivity::class.java).apply{ startActivity(this) } } //if you have created an activity called That Activity it will start it ``` Or you may create ``` fun startoptionsmenufeedback(item : MenuItem){ Toast.makeText(this,"starting feedback items" , Toast.LENGTH_LONG) //this could create a toast } ``` all meant is, it depend on what you actually want perform on that function So, it is impossible to fill the code unless I know what your idea is
21st Feb 2021, 11:24 AM
Ananiya Jemberu
Ananiya Jemberu - avatar
0
Ananiya Jemberu thank you for your answer. What exactly should be in these functions? Sadly, I am a very beginner in Kotlin. Thank you so much for your answer.
20th Feb 2021, 7:17 PM
Tech
0
Ananiya Jemberu ok, thank you. Can you please help me by fill the Code in this function? I've created it after I saw, that Android Studio suggested to create that function. But sadly, I have no idea what I should write in that function to open the fragment. Can you please help me?
21st Feb 2021, 10:05 AM
Tech
0
ok, Ananiya Jemberu I want to open my settings_screen.xml which is located in the app\src\main\res\xml (if this information is nessesary) Followed a html Code which shows the settings_screen.xml file: https://code.sololearn.com/Wu7igTl1euXy/?ref=app
21st Feb 2021, 1:48 PM
Tech