• Android解决button反复点击问题


    public class BaseActivity extends Activity {    
        
        protected boolean isDestroy;
        //防止反复点击设置的标志。涉及到点击打开其它Activity时。将该标志设置为false。在onResume事件中设置为true
        private boolean clickable=true;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            isDestroy=false;
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            
        }
    
        @Override
        protected void onDestroy() {
            super.onDestroy();
            isDestroy=true;
            
        }
    
        @Override
        protected void onResume() {
            super.onResume();
            //每次返回界面时,将点击标志设置为可点击
            clickable=true;
        }
    
        /**
         * 当前能否够点击
         * @return
         */
        protected boolean isClickable(){
            return  clickable;
        }
    
        /**
         * 锁定点击
         */
        protected void lockClick(){
            clickable=false;
        }
    
    
    
        @Override
        public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
            if(isClickable()) {
                lockClick();
                super.startActivityForResult(intent, requestCode,options);
            }
        }
    }

  • 相关阅读:
    ios 读取通讯录
    隐藏多余的分割线
    Cell高亮时设置cell内容
    iOS录音
    iOS发送信息功能(生成信息内容)
    iOS颜色选择器
    iOS缓存
    二维码扫描
    梵讯笔记
    微信开发后台库
  • 原文地址:https://www.cnblogs.com/jhcelue/p/7272433.html
Copyright © 2020-2023  润新知