在设置TextView的比分 [英] Setting the score on textview
问题描述
我想设置在一场比赛的比分,但它不是做此刻什么。
我已经声明了一个得分的变量:
静态INT得分= 0;
当在其他的TextView如图所示的答案正确我希望比分递增,而在另一个文本字段这将是比分显示这一点。
到目前为止,我已经尝试过这样的:
公共无效得分(){
check.getText();
如果(check.equals(正确)){
得分++;
Score.setText(将String.valueOf(分数));}
检查是一个文本框,显示正确或不正确。分数是另一个文本框。
然后我把方法得分()成一个onclick,但这并不更新文本字段。
我想AP preciate对此有何意见。
感谢
编辑:
check.equals(正确)
应
check.getText()。等于(正确)
I am trying to set the score in a game but it isn't doing anything at the moment.
I have declared a score variable:
static int score = 0;
When an answer is shown in another textview as "Correct" I want the score to increment and show this in another textfield which will be for the score.
So far I have tried this:
public void score(){
check.getText();
if(check.equals("Correct")){
score++;
Score.setText(String.valueOf(score));
}
check is a Textfield which shows Correct or Incorrect. Score is another textfield. and then I put the method score() into an onclick, but this doesn't update the textfield.
I would appreciate any advice on this.
Thanks
Edit:
check.equals("Correct")
should be
check.getText().equals("Correct")
这篇关于在设置TextView的比分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!