Hello, you need to create activity in the menu / M...
# announcements
j
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
You want to start your Maps activity? Try startActivity(Intent(this, MapsActivity.class)) (or whatever you named your activity)
j
Yes, ok
I'm still writing a mistake between when (item.itemId) {, the dot is a bug 😞
m
item seems to be nullable (hence the ? in MenuItem?) so the compiler complains that you are not checking for null.
j
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
Try
startActivity(Intent(this, MapsActivity::class.java))
Also may want to post Android related questions to #C0B8M7BUY
j
Its working,Kotlin :))