© Ted Hagos 2018
Ted HagosLearn Android Studio 3 with Kotlinhttps://doi.org/10.1007/978-1-4842-3907-0_11

11. Event Handling

Ted Hagos1 
(1)
Manila, National Capital Region, Philippines
 
What we’ll cover:
  • Listener objects

  • Anonymous inner objects

  • Use of lambdas in event handlers

In the last chapter, we already did some event handling. The part of the exercise where we wrote a function that will increment the value of a text view each time a button is clicked is an exercise on declarative event handling. To bind a function name to a click event, we simply set a View’s android:onClick attribute to the name of a function. This is a simple and low-ceremony way to handle events, but it is limited to only the “click” event. When you need to handle events like ...

Get Learn Android Studio 3 with Kotlin: Efficient Android App Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.