Can you get a resource from a string like this in Kotlin?
val diceImage: ImageView = findViewById(R.id.imageView)
val diceRoll = (1..6).random()
diceImage.setImageResource("R.drawable.dice_${i}")
Can you get a resource from a string like this in Kotlin?
val diceImage: ImageView = findViewById(R.id.imageView)
val diceRoll = (1..6).random()
diceImage.setImageResource("R.drawable.dice_${i}")
You can use the getIdentifier method:
val id = resources.getIdentifier("resourceName", "drawable", packageName)
imageView.setImageResource(id)