Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import java.util.*
*/
class MainActivity : AppCompatActivity() {

lateinit var diceImage : ImageView

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -40,14 +39,16 @@ class MainActivity : AppCompatActivity() {
// Get the Button view from the layout and assign a click
// listener to it.
val rollButton: Button = findViewById(R.id.roll_button)
rollButton.setOnClickListener { rollDice() }
diceImage = findViewById(R.id.dice_image)

val diceImage: ImageView = findViewById(R.id.dice_image)

rollButton.setOnClickListener { rollDice(diceImage) }
}

/**
* Click listener for the Roll button.
*/
private fun rollDice() {
private fun rollDice(diceImage: ImageView) {
// Toast.makeText(this, "button clicked",
// Toast.LENGTH_SHORT).show()
val randomInt = (1..6).random()
Expand Down