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 ...
Get Android Programming with Kotlin for Beginners 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.