在我的应用程序中,我将按钮的图像更改为 1 秒。如何比较按钮的图像。我尝试了很多。请帮助我。当我在 1 秒后更改图像的第一个时间时,它不会改变 agian。它保持不变。下面是代码-
myTimer = new Timer();
myTimer.schedule(new TimerTask() {
@Override
public void run() {
if(time==-1){
onStop();
}
else
runOnUiThread(new Runnable() {
public void run() {
Random rand=new Random();
System.out.println("timer...."+time);
time=time-1;
int num = rand.nextInt(buttonIds.length);
int buttonId = buttonIds[num];
Button bb=(Button) findViewById(buttonId);
if((bb.getBackground()).equals(button.getBackground()))
{
bb.setBackgroundResource(R.drawable.happy);
wrong++;
System.out.println("llllllllllll"+wrong);
}
else
{
bb.setBackgroundResource(R.drawable.whoa);
count++;
System.out.println("mmmmmm"+count);
}
}
});
}
},0, 1000);
}