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
From the course: Programming for Non-Programmers: Android & Kotlin
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
How programming works3m 58s
-
(Locked)
Variables3m 33s
-
(Locked)
Working with variables5m
-
(Locked)
Using properties2m 53s
-
(Locked)
Connect visual objects to variables6m 39s
-
(Locked)
Enum values5m 30s
-
(Locked)
Private properties and constants4m 53s
-
(Locked)
Practical applications of variables2m 22s
-
(Locked)
Challenge: Create two variables1m 9s
-
(Locked)
Solution: Create two variables2m 41s
-
-
-
-
-
-