Hey I'm just a week into Kotlin but I'm struggling with something now. I got this list where I want to put 20 ImageButtons in efficiently with not writing everything individually. I gave all ImageButtons an id that only differs with an integer at the end, for example: takLinks1, takLinks2, takLinks3, ...
I'm trying to do it with a while loop but I can't seem to find the right syntax for Kotlin to do it. Does anyone have an idea how I could tackle this?
private lateinit var takkenLinks: ArrayList<ImageButton>
private fun populateButtonList(){
var i = 1
while (i < 21) {
val takLinks$i = findViewById<ImageButton>(R.id."takLinks$i")
takkenLinks.add(taklinks$i)
}
}