android中button點擊頻率控制(防止按鈕連續點擊的方法)

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

點擊時做出判斷 java

public void onClick(View v) {  
    if (Utils.isFastDoubleClick()) {  
        return;  
    }  
}
相關文章
相關標籤/搜索