I have a button (add) that creates new buttons when pressed (up to 8). But when I try to refer to these buttons and add functionality, I am unable to find the ids' for them. How could I make and find ids' for these buttons?
Note: the button ids should be created automatically when (add) is pressed.
val LLayout: View = layout
var currentId = 0
add.setOnClickListener {
val addedButton = Button(this)
addedButton.text = written.text.toString()
addedButton.id = currentId++
addedButton.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
(LLayout as LinearLayout).addView(addedButton)
//clearing text from EditText written
written.text.clear()
}