July 2018
Intermediate to advanced
400 pages
12h 14m
English
To display the character data in the UI, you will first retrieve each view element that will display text using a function available on NewCharacterActivity (via inheritance) called findViewById.
findViewById accepts a view element id (the android:ids defined in the XML) and returns the view element if a match is found.
In NewCharacterActivity.kt, update onCreate to look up each view element that will display data by its id and assign it to a local variable:
Listing 21.2 Looking up view elements (NewCharacterActivity.kt)
class NewCharacterActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_new_character)
val ...