Android程序防止用户重复点击某一按钮

话不多说,直接罗代码:

首先全局build.grade中添加引用:

  1. buildscript {
  2. dependencies {
  3.         classpath 'cn.leo.plugin:magic-plugin:1.0.0'单击防重
  4.     }
  5. }
  6. allprojects {
  7.     repositories {
  8.         jcenter()
  9.         google()
  10.         maven { url 'https://jitpack.io' }//单击防重
  11.     }
  12. }

其次在app的build.gradle添加引用

顶部

apply plugin: 'cn.leo.plugin.magic'//单击防重

 

dependencies {

    //SingleClick单击防重

    implementation 'com.github.jarryleo:SingleClick:v1.8.3'

}

 

3.代码中

@SingleClick(2000)

@OnClick({R.id.iv_back, R.id.btn_call_1, R.id.btn_call_2})

    public void onViewClicked(View view) {

        switch (view.getId()) {

            case R.id.iv_back:

                finish();

                break;

            case R.id.btn_call_1:

                 break;

            case R.id.btn_call_2:

                  break;

        }

传送门:https://github.com/jarryleo/SingleClick

你可能感兴趣的:(Android)