An event listener is a procedure in an application program that waits for a UI event to occur. There are many types of events that can be emitted within an application. Some common events are click events, touch events, long click events, and text change events.
In order to capture a widget event and perform an action upon its occurrence, a listener for the event must be set to the view. This can be achieved by invoking a view's set. Listener() method and passing either a lambda or a reference to a function to the method invocation.
The following example demonstrates the capturing of a click event done on a button. A lambda is passed to the setOnClickListener method of the view class:
val button: Button = findViewById<Button>(R.id.btn_send) ...