I want to generate random numbers when clicking a button and every random number only occurs once. Now, I have an array in which I store all the generated numbers so I can check whether or not this number has been previously generated. However, when this is the case I want it to generate another number which has not been previously generated. I have been struggling but can't find the right code for this.
var arraylist = ArrayList<Int>()
nextnumberbutton.setOnClickListener {
val rand = java.util.Random().nextInt(75)
if (arraylist.contains(rand)) {
kotlin.run { nextnumberbutton }
} else {
numbertextview.text = rand.toString()
}
arraylist.add(rand)
}