22.4 Saving the State
The first step in extending the StateChange application is to make sure that the text entered by the user is extracted from the EditText component within the onSaveInstanceState() method of the MainActivity activity, and then saved as a key-value pair into the Bundle object.
In order to extract the text from the EditText object we first need to identify that object in the user interface. Clearly, this involves bridging the gap between the Kotlin code for the activity (contained in the MainActivity.kt source code file) and the XML representation of the user interface (contained within the activity_main.xml resource file). In order to extract the text entered into the EditText component we need to gain access to that user interface object.
Each component within a user interface has associated with it a unique identifier. By default, the Layout Editor tool constructs the id for a newly added component from the object type. If more than one view of the same...