禁用进行中的按钮

时间:2019-02-19 09:45:35

标签: java android

有一个持续2秒的过程,在此过程中,我需要锁定整个屏幕和手机的按钮。有一个代码仅禁用取消过程。

public void onClick(View view) {
    int pos = getAdapterPosition();
    dialog= new ProgressDialog(context);
    dialog.setMessage("Please wait ...");
    dialog.setCancelable(false);
    dialog.show();


    if(pos != RecyclerView.NO_POSITION){
        LanguageRecycler clickedDataItem = mData.get(pos);
        SharedPrefManager.getmInstance(context).setCity(clickedDataItem.getAlias());

        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {

                ((Activity)context).finish();

            }
        }, 2000);
    }
}

2 个答案:

答案 0 :(得分:-2)

这将禁用按钮

var StartsWith;
StartsWith = 'txt';
$('[id^=' + StartsWith + ']').each(function () {
    if (this.value == 'myStringToCompare') {
        alert(this.id);
    }
});

答案 1 :(得分:-2)

尝试这个

@Override
   public boolean onKeyDown(int keyCode, KeyEvent event) {
     if (keyCode == KeyEvent.KEYCODE_BACK) {
        //do something or nothing here
      return true;
      }
     return super.onKeyDown(keyCode, event);    
   }