Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Simple Android App with Kotlin Basic Android Programming Accessing Views in Code: Assigning Variables

Anyone with the latest Android studio as of July 2019

// Assign views to their corresponding variables factTextView = findViewById(R.id.textView2) showFactButton = findViewById(R.id.button) showFactButton!!.setOnClickListener { val fact = "Ostriches can run faster than horses" factTextView!!.text =fact

Anything that follows (R.id.....), what comes after id should be the id of your text view or your button which you will get from the layout information provided in the right panel when you either click on the text view or button

1 Answer

Tonnie Fanadez
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tonnie Fanadez
UX Design Techdegree Graduate 22,796 Points

PEARL KENGAJU thanks, I am working with the July 2019 version and thanks for the info. However, I can't see the right panel that you have mentioned. Would you kindly take a snapshot and provide the link to the snapshot for our understanding. Thanks,