If I do this, it sometimes sets the same image as it was in image_view
. For example, if R.drawable.cat__5_
is in image_view
I want to select from R.drawable.cat__3_,R.drawable.cat__4_,R.drawable.cat__6_,R.drawable.cat__7_,R.drawable.cat__8_.
How it can be done?
var cats = intArrayOf(
R.drawable.cat__3_,
R.drawable.cat__4_,
R.drawable.cat__5_,
R.drawable.cat__6_,
R.drawable.cat__7_,
R.drawable.cat__8_)
button.setOnClickListener{
random = Random()
image_view.setImageResource(cats[random.nextInt(cats.size)])
Aucun commentaire:
Enregistrer un commentaire