//代码2
public
abstract
class
NoDoubleClickListener
implements
OnClickListener {
public
static
final
int
MIN_CLICK_DELAY_TIME =
1000
;
private
long
lastClickTime =
0
;
@Override
public
void
onClick(View v) {
long
currentTime = Calendar.getInstance().getTimeInMillis();
if
(currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
lastClickTime = currentTime;
onNoDoubleClick(v);
}
}
}
//代码3
submitButton.setOnClickListener(
new
NoDoubleClickListener() {
@Override
public
void
onNoDoubleClick(View v) {
submitOrder();
}
});
注意: MIN_CLICK_DELAY_TIME 此时间一定要稍长一点, 比如: 1秒, 因为在魅族手机上设置400毫秒的间隔, 快速点击则不被视为快速点击