标签:
=================================
//代码2
public abstract class NoDoubleClickListener implements OnClickListener {
public static final int MIN_CLICK_DELAY_TIME = 1000;
private long lastClickTime = 0;
public abstract onNoDoubleClick(View view);
@Override
public void onClick(View v) {
long currentTime = Calendar.getInstance().getTimeInMillis();
if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
lastClickTime = currentTime;
onNoDoubleClick(v);
}
}
}
使用方法;给submitButton设置点击事件时用NoDoubleClickListener代替OnClickListener,并且实现方法onNoDoubleClick代替onClick即可,像这样:
//代码3
submitButton.setOnClickListener(new NoDoubleClickListener() {
@Override
public void onNoDoubleClick(View v) {
submitOrder();
}
});
标签:
原文地址:http://www.cnblogs.com/awkflf11/p/5894153.html