The overriding purpose for using Kotlin is to reduce the amount of code you have to write compared to Java. One of the most common bits of Java boilerplate code in Android is the use of anonymous interface implementations as event handler objects. In Kotlin, however, you should use lambda expressions to handle events and other situations that require anonymous interface implementations.
- [Instructor] Kotlin's overriding purpose…is to reduce the amount of code…you have to write compared to Java.…One of the most common bits of Java boiler plate code…in Android is the use of anonymous interface implementations…as event handler objects.…You can implement that sort of code in Kotlin,…but it doesn't look very good.…In this version of my application,…my event handler is implemented in my layout file.…It's called ContentMain.xml,…and there are two buttons declared in this file,…one called run button and the other clear button.…
They both have on click event handlers…declared in the layout as xml attributes.…I'm going to get rid of the on click attribute…for the run button, and then I'll create some Kotlin code…that will take care of that in the main activity file.…As always, when you want to declare an event handler,…you need a reference to the button or other view object.…I'll declare an immutable variable that I'll name run button…and I'll get its value with find view by id…and I'll declare this as a view object.…
Skill Level Intermediate
Q: Why can't I earn a Certificate of Completion for this course?
A: We publish a new tutorial or tutorials for this course on a regular basis. We are unable to offer a Certificate of Completion because it is an ever-evolving course that is not designed to be completed. Check back often for new movies.
Android App Development: Data Persistence Librarieswith Annyce Davis4h 52m Intermediate
Building Android Apps with Cloud Serviceswith Albert Lo2h 37m Intermediate
1. Android Development Tips Weekly
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.