Android Studio Tutorial: Replacing findViewById with Kotlin Synthetic Imports

Old way:

findViewById() (the old way).

New way:

Kotlin synthetic import.

This is possible because of Kotlin synthetic imports. Just type the TextView's ID, that's it.

The TextView.

Just make sure the TextView has an ID that matches the Kotlin code. For clarity, here is the Kotlin import:

The imports that make this possible.

Published by Daniel Malone

Daniel Malone is an Android Developer in Austin, Texas. He enjoys writing code, whether it be HTML, CSS, JavaScript, PHP, Java, XML or Kotlin. Daniel started writing code at age 12. By the time he was 15, he had a technology news website that received about 200 visitors a day. His first computer was a Dell Dimension 3000, with an 80GB hard drive, 512MB RAM and a broken DVD drive.