gpt4 book ai didi

java - 在android中单击按钮时更改textview文本颜色

转载 作者:太空宇宙 更新时间:2023-11-04 10:09:00 24 4
gpt4 key购买 nike

我有 Android Studio 中测验游戏的代码。当我的答案正确时,我需要更改 TextView 中文本的颜色,但在我的代码中,当问题是下一个时,按钮颜色会发生变化。我点击正确答案,但颜色放入下一个问题。你能帮我吗?

respuesta1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

if(respuesta1.getText() == respuestaCorrecta){ //if the answer is correct


puntos += 3;
puntuacion.setText("Puntuacion: " +puntos);
Toast.makeText(MainActivity.this, acertado, Toast.LENGTH_SHORT).show();
acierto.start(); //this is de sound
respuesta1.setBackgroundColor(Color.parseColor("#76FF03")); //change color to green

try {
sleep(800);
} catch (InterruptedException e) {
e.printStackTrace();
} //wait for change to other question


if(numeroPregunta<9){
numeroPregunta+=1;
preguntaMostrar(numeroPregunta); //show the next question

}else if(numeroPregunta == 9){

pantallaImagen.putExtra("puntuacionActual", puntos);
startActivity(pantallaImagen); //go to the final activity
}

最佳答案

acierto.start(); 的作用是什么?

我认为你应该把 respuesta1.setBackgroundColor(Color.parseColor("#76FF03")); 放在前面。

关于java - 在android中单击按钮时更改textview文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52568299/

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