Android-如何防止用户过快频繁点击按钮(四)

这是最后成功的办法 ---关于防止用户过快频繁的点击按钮事件spa

public class SmButton {
public static class Utils {
    public static final int DELAY = 2000;
    public static long lastClickTime = 0;
    public static boolean isNotFastClick(){
        long currentTime = System.currentTimeMillis();
        if (currentTime - lastClickTime > DELAY) {
            lastClickTime = currentTime;
            return true;
        }else{return false;}
    }
}

}事件

 

而后在点击事件中下面写ast

if(SmButton.Utils.isNotFastClick()){
    //您的代码}
相关文章
相关标签/搜索