The express yourself demo app
Let's try using some declarations, assignments, and operators. When we bundle these elements together into some meaningful syntax, we call it an expression. Let's write a quick app to try some out. We will then use Toast
and Log
to check our results.
Create a new project called Express Yourself
, use an Empty Activity project template, and leave all the other options in their usual settings. The completed code that we will write in this project can be found in the Chapter07
folder of the download bundle.
Switch to the MainActivity tab in the editor and we will write some code. In the onCreate
function, just before the closing curly brace (}
), add this highlighted code:
class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val name = "Nolan Bushnell" val yearOfBirth = 1943 var currentYear = 2019 ...