The Kotlin Extensions for Android include a tool to create view reference variables based on an XML layout. In this video, create the required dependencies and imports.
- [Instructor] When you program Android apps with Kotlin, … you get a lot of special features … beyond the language itself. … One of these is a tool called synthetic view binding. … When you create a brand-new Android app in Android Studio … it'll typically have this import at the top, … referencing an activity layout file. … Activity_main.xml is the primary layout file. … And it has a couple of components that have IDs assigned. … So there's a toolbar component … that has and ID of toolbar … and a floating action button that has an ID of fab. … In the MainActivity class there … are references to these components, … here for the toolbar and here … for the floating action button. … There isn't any apparent code … that's creating those variables. … Instead, this import statement is creating … a bunch of generated code in the background. … It's interrogating the layout files, … finding view components that have IDs … and then creating the variables that you need. … Now you can do the same thing for other components …
Looking for study partners?Join the Associate Android Developer Exam study group
The Android app architecture constantly evolves. The introduction of the Kotlin programming language, new form factors such as Chromebooks, and reusable architecture components have made it faster and easier than ever to build high-quality Android apps. It is imperative that developers understand what the latest tools and recommendations are and how to use them to build out their applications. In this course, instructor David Gassner explains how to build an Android app that uses Kotlin instead of Java, add navigation functionality, and leverage the most useful architecture components such as LifecycleObserver, ViewModel, and LiveData, to create apps that are robust and easy to maintain over time.
- Handling lifecycle events
- Handling view events
- Updating display from new data
- Adding ViewModels to activities
- Subscribing to changes in LiveData values
- Adding a new launcher activity
- Starting activities with explicit intents
- Sharing data with implicit intents
- Adding a navigation drawer
- Adding a header to a navigation drawer
- Handling navigating drawer menu events