I recently learned that some Kotlin plugins allow for accessing view names from XML directly in Kotlin. This alleviates the need to create widgets in Kotlin and use “findViewByID” to initialize them. However, the Android Programming 4th edition book does not take advantage of this shortcut and does create the widgets, etc. So I have a two part question:
- Are there any disadvantages to using the plug-in/shortcut? Or stated another way, are there any advantages to actually creating and initializing the widgets?
- I was able to use the shortcut without the import statement in the subject, and I’m not sure why it worked. Here are my imports:
So why did it work WITHOUT the import kotlinx.android.synthetic.main.activity_main.* ?
Thanks in advance!