I want to set random image from array
var randomElement = array[random.nextInt(array.size)]
image_view.setImageResource(randomElement)
But after that don't repeat it
button.setOnClickListener {
if (image_view.drawable.constantState != ContextCompat.getDrawable(
this,
R.drawable.myImage
)?.constantState{
var randomElement = array[random.nextInt(array.size)] //but exclude R.drawable.myImage
}
}
How it can be excluded from array and after that added to avoid repeating only last previous image?
Aucun commentaire:
Enregistrer un commentaire