31.6 Adding the EditText View
The next item to be added to the layout is the EditText view. The first step is to create the EditText object, assign it the ID as declared in the id.xml resource file and add it to the layout. The code changes to achieve these steps now need to be made to the configureLayout() method as follows:
private fun configureLayout() {
val myButton = Button(this)
myButton.text = getString(R.string.press_me)
myButton.setBackgroundColor(Color.YELLOW)
myButton.id = R.id.myButton
val myEditText = EditText(this)
myEditText.id = R.id.myEditText
val myLayout = ConstraintLayout(this)
myLayout.setBackgroundColor(Color.BLUE)
myLayout.addView(myButton)
myLayout.addView(myEditText...