val editText1 = findViewById<EditText>(R.id.editText1);
if(comNum != editText1.toString().toInt() ){
View4.text = "오답"
} else View4.text = "정답"
The installed apk
is not working. I think edittext.toString.toInt
is wrong.
val editText1 = findViewById<EditText>(R.id.editText1);
if(comNum != editText1.toString().toInt() ){
View4.text = "오답"
} else View4.text = "정답"
The installed apk
is not working. I think edittext.toString.toInt
is wrong.
Get the String
out of EditText
: editText1.getText().toString().toInt()
Wrong
editText1.toString().toInt()
It should be
editText1.text.toString().toInt()
FYI
toInt()
Parses the string as an Int number and returns the result. if the string is not a valid representation of a number you will receive NumberFormatException .
Try this
val editText1 = findViewById<EditText>(R.id.editText1);
if(comNum != Integer.parseInt(editText1.text.toString()) ){
View4.text = "오답"
} else View4.text = "정답"
Try below code, you can not using editText1.toString().toInt()
var value: Int
try {
value = editText1.text.toString().toInt();
} catch (e: NumberFormatException) {
// value of editText1 is a invalid Integer
}
if(comNum != value ){
View4.text = "오답"
} else View4.text = "정답"
hope this helps