From the course: Programming for Non-Programmers: Android & Kotlin

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Create two variables

Solution: Create two variables

From the course: Programming for Non-Programmers: Android & Kotlin

Start my 1-month free trial

Solution: Create two variables

(delicate music) - [Instructor] So here is one way to solve the challenge. I'm going to start in my activity main xml file. Remember, you can find that under App, Res, Layout. And there it is, activitymain.xml. So I'll close the project window. And what I'm going to do first is give Hello World an I.D. So I'll click on Hello World, that little text view right there, and then click in the Attributes area in that ID field, and type out TextView with a capital V, and press return or enter to commit the change. Let's head over to our Kotlin file, mainactivity, and then, inside of here, I'm going to create two constants, and then put those values inside of our TextView. So below all the rest of the existing code inside of oncreate, right below Set Content View and above that closed curly brace, I'm going to create one value. So val, we're not going to use var here, because we're not going to be changing this value. We'll call this Name. Set it equal to the string Diane. On the next line…

Contents