Capture User-Entered Data
The first new method needed is used to capture the user data as it’s typed and store it in the currentContact
object. The method itself does not capture the data. Rather, it sets up listeners on all the EditText
s where data can be entered. If the text changes, the listener then executes the code to set the attribute that holds the code in the currentContact
object. The method is called in the onCreate
method of the ContactActivity
so that the listeners are ready to go when the ContactActivity
is ready for input. To start, enter the following line of code after all the other init methods in the onCreate
method:
initTextChangedEvents();
Next, create a new method in the ContactActivity
class called initTextChangedEvents() ...
Get Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.