我正在做一个游戏,其中包括两项活动。
我有一个第一次点击后关闭按钮
static class ModelGetter: public static int getPoint{int static point++;}
。
当单击第一个活动的按钮时,计数器加 我怎样才能避免在同一个活动,如果我按两次相同按键计数器不incremente计数器两次,但只有一个?
我正在做一个游戏,其中包括两项活动。
我有一个第一次点击后关闭按钮
static class ModelGetter: public static int getPoint{int static point++;}
。
当单击第一个活动的按钮时,计数器加 我怎样才能避免在同一个活动,如果我按两次相同按键计数器不incremente计数器两次,但只有一个?
很简单:onClick
里面,你需要禁用按钮:
yourButton.setEnabled(false);
所以,当你重新尝试点击它,什么都不会发生,因为按钮现已停用。
的COMPLE代码将是:
yourButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
v.setEnabled(false);
// increment what you want, or other stuff..
}
});
谢谢你的帮助,我解决它。 – BarcelonaDev 2014-10-02 21:49:03
您可以添加onclick处理程序一样 -
document.getElementById("buttonId").onclick = function() {
this.disabled = true; // it will disable your button
//do whatever your logic here or increment your value
}
,或者您可以拨打像按钮的onclick功能 -
function clickButton(){
getElementById("buttonId").disabled=true;
//do whatever your logic here or increment your value
}
这就是Javascript Moni。 Java和Javascript是非常不同的。 – 2016-12-03 00:27:28
那并不看起来像Java – khelwood 2014-10-02 19:34:40