https://kotlinlang.org logo
Title
j

jurajsolarml

08/24/2018, 11:15 AM
Hello, you need to create activity in the menu / Mapa. Maps_activity is already created but located elsewhere. How can I do this? You can help me? I am a beginner. This is not working, it writes a mistake. Thank you Juraj override fun onOptionsItemSelected(item: MenuItem?): Boolean { when(item.itemId) { R.id.Mapa -> { startActivity(Intent(this, activity_maps::class.java)) return true } } return false } }
m

Morten

08/24/2018, 11:27 AM
You want to start your Maps activity? Try startActivity(Intent(this, MapsActivity.class)) (or whatever you named your activity)
j

jurajsolarml

08/24/2018, 11:35 AM
Yes, ok
I'm still writing a mistake between when (item.itemId) {, the dot is a bug 😞
m

Morten

08/24/2018, 12:11 PM
item seems to be nullable (hence the ? in MenuItem?) so the compiler complains that you are not checking for null.
j

jurajsolarml

08/24/2018, 12:34 PM
ok,thanks
override fun onOptionsItemSelected(item: MenuItem?): Boolean { when (item?.itemId) { R.id.action_Mapa -> { startActivity(Intent(this, MapsActivity.class)) <- expeciting ')' } } return false } } it does not work it bugs :((
e

Erik

08/24/2018, 1:43 PM
Try
startActivity(Intent(this, MapsActivity::class.java))
Also may want to post Android related questions to #android
j

jurajsolarml

08/24/2018, 2:51 PM
Its working,Kotlin :))