当前位置:   article > 正文

防止重复点击工具类_onnodoubleclicklistener

onnodoubleclicklistener
防止重复点击
  1. import android.view.View;
  2. import java.util.Calendar;
  3. /**
  4. * des:防止重复点击
  5. * Created by xsf
  6. * on 2016.05.9:29
  7. */
  8. public abstract class OnNoDoubleClickListener implements View.OnClickListener {
  9. public static final int MIN_CLICK_DELAY_TIME = 1000;
  10. private long lastClickTime = 0;
  11. @Override
  12. public void onClick(View v) {
  13. long currentTime = Calendar.getInstance().getTimeInMillis();
  14. if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
  15. lastClickTime = currentTime;
  16. onNoDoubleClick(v);
  17. }
  18. }
  19. protected abstract void onNoDoubleClick(View v);
  20. }

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/694076
推荐阅读
相关标签
  

闽ICP备14008679号