Coding the widget exploration app
The first part of the Kotlin code that we need to change is to make sure that our new layout is displayed. We can do so by changing the call to the setContentView function in the onCreate function to look like this:
setContentView(R.layout.exploration_layout)
There are many import statements that are needed for this app, so let's add them all up front to save us from having to keep mentioning them as we proceed. Add the following import statements:
import androidx.appcompat.app.AppCompatActivity
import android.graphics.Color
import android.os.Bundle
import android.view.View
import android.widget.CompoundButton
import android.widget.RadioButton
import kotlinx.android.synthetic.main.exploration_layout.*
The preceding code also includes the …exploration_layout.* code (as highlighted in the preceding code) to automatically enable us to use the id attributes that we have just configured as the instance names in our Kotlin code. This saves us from using...