当我的计时器达到一定数量时,它会停止。相反,我希望它停止点击按钮。我怎么做? 这是我的代码看起来像现在:如何让定时器停止点击
final TextView t1 = (TextView) findViewById(R.id.yourpay);
final Timer t =new Timer();
t.schedule(new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
public void run() {
money = (PPS+Reserve);
Reserve = (money);
t1.setText("$" + money); //Place your text data here
counter++;
//Place your stopping condition over here. Its important to have a stopping condition or it will go in an infinite loop.
if(counter == HPDPS)
t.cancel();
}
});
}
}, 1000, 1000);
如果可能的话,我想它停止按钮点击,当计数器达到HPDPS。
你能告诉我一个例子,我可以建立过的?就像我说的那样,真的很新,所以我真的不知道如何格式化onClickListener – Hockeyman271 2012-07-30 18:00:48
有一个更新的代码示例。试试那个。 – Mxyk 2012-07-30 18:09:41
非常感谢所有的帮助! @override出现了一些错误,所以我不得不删除它?我不知道为什么 – Hockeyman271 2012-07-30 19:27:43