android 防止按钮连续点击的方法(Button,ImageButton等)

public class Utils {
    private static long lastClickTime;
    public static boolean isFastDoubleClick() {
        long time = System.currentTimeMillis();
        long timeD = time - lastClickTime;
        if ( 0 < timeD && timeD < 500) {   
            return true;   
        }   
        lastClickTime = time;   
        return false;   
    }
}

调用

 
public void onClick(View v) {
    if (Utils.isFastDoubleClick()) {
        return;
    }
}

原文地址:http://kewell2004.iteye.com/blog/1545783

posted on 2012-10-24 18:13  Tristan2012  阅读(1768)  评论(0)    收藏  举报