How to get a resource from string in Kotlin? [duplicate]

  android, android-resources, kotlin

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}")

Source: Android Questions

LEAVE A COMMENT