Created
October 26, 2017 13:18
-
-
Save vahids/f3a5c68ba11ff3b231936f83e4e060c3 to your computer and use it in GitHub Desktop.
My First Kotlin class
This file contains hidden or 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() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) | |
| configureViewElements() | |
| } | |
| private fun configureViewElements() { | |
| configureSubmitButton() | |
| } | |
| private fun configureSubmitButton() { | |
| val submit = findViewById<Button>(R.id.submitFormBtn) | |
| submit.setOnClickListener { | |
| this.showMessage("Submiting form...", true) | |
| } | |
| } | |
| private fun showMessage(msg: String, darkBackground: Boolean) { | |
| val toast = Toast.makeText(this@MainActivity, msg, Toast.LENGTH_SHORT) | |
| if (darkBackground) { | |
| toast.view.setBackgroundColor(Color.GRAY) | |
| } | |
| toast.show() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment