gpt4 book ai didi

java - EditText 没有为测验应用程序的满分添加分数

转载 作者:行者123 更新时间:2023-12-01 17:49:31 25 4
gpt4 key购买 nike

在我的测验应用程序中,我通过按钮和复选框获得分数,但编辑文本问题在正确时不会被计算在内。这是我的一个 edittext 字段的 java 代码:

EditText question2_answer = findViewById(R.id.question2_answer);
if (question2_answer.equals("Surrounding membrane, Cytoplasm and Nucleus")) {
question2_score = 1;
} else {
question2_score = 0;
}

最佳答案

您应该使用 getText().toString() 以便您可以在 EditText 中获取输入的文本

EditText question2_answer = findViewById(R.id.question2_answer);
if (question2_answer.getText().toString().equals("Surrounding membrane, Cytoplasm and Nucleus")) {
question2_score = 1;
} else {
question2_score = 0;
}

关于java - EditText 没有为测验应用程序的满分添加分数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51954887/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com