Answered step by step
Verified Expert Solution
Question
1 Approved Answer
App keeps stopping' error when the app is launched. scan the code and fix the errors that may be causing this problem. package com.example.diceroller import
App keeps stopping' error when the app is launched. scan the code and fix the errors that may be causing this problem.
package com.example.diceroller
import android.osBundle
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity
override fun onCreatesavedInstanceState: Bundle?
super.onCreatesavedInstanceState
setContentViewRlayout.activitymain
val rollButton: Button findViewByIdRidrollButton
rollButton.setOnClickListener
rollDice
private fun rollDice
val diceImage: ImageView findViewByIdRiddiceImage
val diceImage: ImageView findViewByIdRiddiceImage
val totalTextView: TextView findViewByIdRidtotalTextView
val dicerandom
val dicerandom
val total dice dice
diceImagesetImageResourcegetDiceImagedice
diceImagesetImageResourcegetDiceImagedice
totalTextView.text "Sum: $total"
private fun getDiceImagediceValue: Int: Int
return when diceValue
Rdrawable.dice
Rdrawable.dice
Rdrawable.dice
Rdrawable.dice
Rdrawable.dice
else Rdrawable.dice
xml:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started