Created
September 28, 2018 14:58
-
-
Save tedhagos/0c71980dd9f3c98a90e74677c72f9ada to your computer and use it in GitHub Desktop.
Using when in an Android app
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 MainActivity : AppCompatActivity() { | |
val Log = Logger.getLogger(MainActivity::class.java.name) | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
} | |
override fun onCreateOptionsMenu(menu: Menu?): Boolean { | |
Log.info("onCreateOptionsMenu") | |
menu?.add("File") | |
menu?.add("Exit") | |
return super.onCreateOptionsMenu(menu) | |
} | |
override fun onOptionsItemSelected(item: MenuItem?): Boolean { | |
when (item?.toString()) { | |
"File" -> { | |
Log.info("LOG File menu") | |
} | |
"Exit" -> { | |
Log.info("LOG Exit menu") | |
} | |
} | |
return true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment