May 2022
Intermediate to advanced
688 pages
20h 12m
English
How do XML elements in activity_main.xml become View objects? The answer starts in the MainActivity class.
When you created the GeoQuiz project, a subclass of Activity named MainActivity was created for you. The class file for MainActivity is in the app/java directory of your project.
A quick aside about the directory name before we get into how layouts become views: This directory is called java because Android originally supported only Java code. In your project, because you configured it to use Kotlin (and Kotlin is fully interoperable with Java), the java directory is where the Kotlin code lives. You could create a kotlin directory and place your Kotlin files there, but that would provide no ...
Read now
Unlock full access