26.4 An Event Handling Example
In the remainder of this chapter, we will work through the creation of an Android Studio project designed to demonstrate the implementation of an event listener and corresponding callback method to detect when the user has clicked on a button. The code within the callback method will update a text view to indicate that the event has been processed.
Select the Create New Project quick start option from the welcome screen and, within the resulting new project dialog, choose the Empty Activity template before clicking on the Next button.
Enter EventExample into the Name field and specify com.ebookfrenzy.eventexample as the package name. Before clicking on the Finish button, change the Minimum API level setting to API 26: Android 8.0 (Oreo) and the Language menu to Java.
Designing the User Interface
The user interface layout for the MainActivity class in this example is to consist of a ConstraintLayout, a Button and a TextView as illustrated in...