[英]change the color of the two buttons in Android
正確時更改兩個按鈕的顏色
我有一個游戲,比較左側和右側的按鈕。 當您單擊左側並將其與右側進行比較時,正確的2個按鈕必須為綠色。 我該如何實施呢?
public void getClick1(int num)
{
firstClick = arrNum1[num];
}
public void getClick2(int num){
secondClick = arrNum2[num];
if (firstClick == secondClick){
guess.setText(Integer.toString(--score ));
}else{
Toast.makeText(this,"WRONG!", Toast.LENGTH_LONG).show();
}
}
您可以使用以下方法更改Button
的顏色:
btn2.setBackgroundColor(Color.RED);
...其中btn2
是Button
的實例。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.